Revision: 200949
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 09:14:18 +0200
changeset 0 f58d6ec98e88
child 1 b700e12870ca
Revision: 200949 Kit: 200951
aknlayoutcompiler/binary/AknLayoutCompiler.exe
aknlayoutcompiler/cdl/MasterLayoutPack.cdl
aknlayoutcompiler/group/AknLayoutCompiler.mmp
aknlayoutcompiler/group/bld.inf
aknlayoutcompiler/inc/AdaptationLayerTemplate.h
aknlayoutcompiler/inc/Cdl2Lag.h
aknlayoutcompiler/inc/CodeGenConsts.h
aknlayoutcompiler/inc/CoreParser.h
aknlayoutcompiler/inc/CppWriter.h
aknlayoutcompiler/inc/Extract.h
aknlayoutcompiler/inc/FormulaParser.h
aknlayoutcompiler/inc/FormulaTree.h
aknlayoutcompiler/inc/HtmlParse.h
aknlayoutcompiler/inc/Lay2Cdl.h
aknlayoutcompiler/inc/Lay2LayPerf.h
aknlayoutcompiler/inc/Lay2MLInst.h
aknlayoutcompiler/inc/LayCdl2Inst.h
aknlayoutcompiler/inc/LayCdl2InstO.h
aknlayoutcompiler/inc/LayCdlCheck.h
aknlayoutcompiler/inc/LayPerfWriter.h
aknlayoutcompiler/inc/LayScale.h
aknlayoutcompiler/inc/Layout.h
aknlayoutcompiler/inc/LayoutCompilerErr.h
aknlayoutcompiler/inc/LayoutConfig.h
aknlayoutcompiler/inc/LayoutPack.h
aknlayoutcompiler/inc/LayoutParse.h
aknlayoutcompiler/inc/LayoutWriter.h
aknlayoutcompiler/inc/MLAttributes.h
aknlayoutcompiler/inc/MLAttributesParse.h
aknlayoutcompiler/inc/MLCompCdl2InstO.h
aknlayoutcompiler/inc/MLCompData.h
aknlayoutcompiler/inc/MLCompData2Cdl.h
aknlayoutcompiler/inc/MLCompData2LayPerf.h
aknlayoutcompiler/inc/MLCompDataLayPerfWriter.h
aknlayoutcompiler/inc/MLCompDataParse.h
aknlayoutcompiler/inc/MLEqCompData.h
aknlayoutcompiler/inc/MLEqCompData2DHuiML.h
aknlayoutcompiler/inc/MLEqCompDataParse.h
aknlayoutcompiler/inc/MakeLayConvTest.h
aknlayoutcompiler/inc/MasterLayoutPack.h
aknlayoutcompiler/inc/SaxErrorHandler.h
aknlayoutcompiler/inc/Script.h
aknlayoutcompiler/inc/UpdateLayoutApi.h
aknlayoutcompiler/inc/UsefulDefinitions.h
aknlayoutcompiler/inc/WriterBase.h
aknlayoutcompiler/inc/ZoomLevelNames.h
aknlayoutcompiler/src/AdaptationLayerTemplate.cpp
aknlayoutcompiler/src/AknLayoutCompiler.cpp
aknlayoutcompiler/src/Cdl2Lag.cpp
aknlayoutcompiler/src/CoreParser.cpp
aknlayoutcompiler/src/CppWriter.cpp
aknlayoutcompiler/src/Extract.cpp
aknlayoutcompiler/src/FormulaParser.cpp
aknlayoutcompiler/src/FormulaTree.cpp
aknlayoutcompiler/src/HtmlParse.cpp
aknlayoutcompiler/src/Lay2Cdl.cpp
aknlayoutcompiler/src/Lay2LayPerf.cpp
aknlayoutcompiler/src/Lay2MLInst.cpp
aknlayoutcompiler/src/LayCdl2Inst.cpp
aknlayoutcompiler/src/LayCdl2InstO.cpp
aknlayoutcompiler/src/LayCdlCheck.cpp
aknlayoutcompiler/src/LayPerfWriter.cpp
aknlayoutcompiler/src/LayScale.cpp
aknlayoutcompiler/src/Layout.cpp
aknlayoutcompiler/src/LayoutCompilerErr.cpp
aknlayoutcompiler/src/LayoutConfig.cpp
aknlayoutcompiler/src/LayoutPack.cpp
aknlayoutcompiler/src/LayoutParse.cpp
aknlayoutcompiler/src/LayoutWriter.cpp
aknlayoutcompiler/src/MLAttributes.cpp
aknlayoutcompiler/src/MLAttributesParse.cpp
aknlayoutcompiler/src/MLCompCdl2InstO.cpp
aknlayoutcompiler/src/MLCompData.cpp
aknlayoutcompiler/src/MLCompData2Cdl.cpp
aknlayoutcompiler/src/MLCompData2LayPerf.cpp
aknlayoutcompiler/src/MLCompDataLayPerfWriter.cpp
aknlayoutcompiler/src/MLCompDataParse.cpp
aknlayoutcompiler/src/MLEqCompData.cpp
aknlayoutcompiler/src/MLEqCompData2DHuiML.cpp
aknlayoutcompiler/src/MLEqCompDataParse.cpp
aknlayoutcompiler/src/MakeLayConvTest.cpp
aknlayoutcompiler/src/MasterLayoutPack.cpp
aknlayoutcompiler/src/SaxErrorHandler.cpp
aknlayoutcompiler/src/Script.cpp
aknlayoutcompiler/src/UpdateLayoutApi.cpp
aknlayoutcompiler/src/WriterBase.cpp
aknlayoutcompiler/src/ZoomLevelNames.cpp
cdlcompiler/binary/CdlCompiler.EXE
cdlcompiler/group/CdlCompiler.mmp
cdlcompiler/group/bld.inf
cdlcompiler/src/CdlCompiler.cpp
cdlcompiler/test/Ex1.cdl
cdlcompiler/test/Ex2.cdl
cdlcompilertoolkit/bmarm/CDLU.DEF
cdlcompilertoolkit/bwins/CDLU.DEF
cdlcompilertoolkit/group/CdlCompilerToolkit.dep
cdlcompilertoolkit/group/CdlCompilerToolkit.dsp
cdlcompilertoolkit/group/CdlCompilerToolkit.mak
cdlcompilertoolkit/group/CdlCompilerToolkit.mmp
cdlcompilertoolkit/group/bld.inf
cdlcompilertoolkit/inc/CdlTkPriv.h
cdlcompilertoolkit/inc/CdlTkStdTrans.h
cdlcompilertoolkit/src/CdlTkClientHeader.cpp
cdlcompilertoolkit/src/CdlTkDll.cpp
cdlcompilertoolkit/src/CdlTkInstance.cpp
cdlcompilertoolkit/src/CdlTkInterface.cpp
cdlcompilertoolkit/src/CdlTkInterfaceCheck.cpp
cdlcompilertoolkit/src/CdlTkPackage.cpp
cdlcompilertoolkit/src/CdlTkParser.cpp
cdlcompilertoolkit/src/CdlTkProcess.cpp
cdlcompilertoolkit/src/CdlTkSourceFileWriter.cpp
cdlcompilertoolkit/src/CdlTkSyntaxCheck.cpp
cdlcompilertoolkit/src/CdlTkUtil.cpp
cdlcompilertoolkit/src/CdlTkWriteCdlFile.cpp
cdlcompilertoolkit/src/CdlTkWriteCommonDefs.cpp
cdlcompilertoolkit/src/CdlTkWriteDll.cpp
cdlcompilertoolkit/src/CdlTkWriteInstance.cpp
gfxtools/Color/group/Color.mmp
gfxtools/Color/group/bld.inf
gfxtools/Color/group/convcolor.mk
gfxtools/Color/inc/Color.h
gfxtools/Color/inc/ColorImp.h
gfxtools/Color/inc/RGB.H
gfxtools/Color/src/Color.cpp
gfxtools/Color/src/Main.cpp
gfxtools/Color/src/NokiaBlue.cpp
gfxtools/Color/src/NokiaGreen.cpp
gfxtools/Color/src/NokiaGrey.cpp
gfxtools/Color/src/NokiaPurple.cpp
gfxtools/Color/src/Palette1.cpp
gfxtools/Color/src/Palette10.cpp
gfxtools/Color/src/Palette11.cpp
gfxtools/Color/src/Palette12.cpp
gfxtools/Color/src/Palette13.cpp
gfxtools/Color/src/Palette2.cpp
gfxtools/Color/src/Palette3.cpp
gfxtools/Color/src/Palette4.cpp
gfxtools/Color/src/Palette5.cpp
gfxtools/Color/src/Palette6.cpp
gfxtools/Color/src/Palette7.cpp
gfxtools/Color/src/Palette8.cpp
gfxtools/Color/src/Palette9.cpp
gfxtools/Color/src/RGB.CPP
gfxtools/Color/src/SchemeOrange.cpp
gfxtools/Color/src/SchemePink.cpp
gfxtools/Color/src/SchemeRed.cpp
gfxtools/Color/src/strings.cpp
gfxtools/gditools/fontcomp/DISTRIBUTION.POLICY
gfxtools/gditools/fontcomp/EFF.CPP
gfxtools/gditools/fontcomp/FONTCOMP.CPP
gfxtools/gditools/fontcomp/FONTCOMP.H
gfxtools/gditools/fontcomp/FSC.CPP
gfxtools/gditools/fontcomp/GDSFCOMP.CPP
gfxtools/gditools/fontcomp/GDSFCOMP.H
gfxtools/gditools/group/DISTRIBUTION.POLICY
gfxtools/gditools/group/FONTCOMP.MMP
gfxtools/gditools/group/Makefile.bmconv
gfxtools/gditools/group/bld.inf
gfxtools/gditools/group/fontcomp.ipr
gfxtools/gditools/inc/DISTRIBUTION.POLICY
gfxtools/gditools/inc/TOOLSVER.H
gfxtools/gditools/rom/gdi.iby
gfxtools/group/bld.inf
group/bld.inf
layers.sysdef.xml
package_definition.xml
reszip/group/bld.inf
reszip/group/reszip.bat
reszip/group/reszip.mmp
reszip/group/reszip_eka2.bat
reszip/inc/rescomp.h
reszip/inc/resdict.h
reszip/inc/resentry.h
reszip/src/rcmp.cpp
reszip/src/rescomp.cpp
reszip/src/resdict.cpp
reszip/src/resentry.cpp
skincompiler/AknSkinDescCompiler/group/bld.inf
skincompiler/group/bld.inf
svgtencoder/group/bld.inf
svgtencoder/svgtenc/standalone/group/SVGEncoder_CPP.dsp
svgtencoder/svgtenc/standalone/group/SVGEncoder_CPP.dsw
svgtencoder/svgtenc/standalone/group/SYMDEFCPPDLL.dsp
svgtencoder/svgtenc/standalone/group/bld.inf
svgtencoder/svgtenc/standalone/group/copysvgtbinencode.mk
svgtencoder/svgtenc/standalone/group/makefile
svgtencoder/svgtenc/standalone/group/svgtbinencoder.mk
svgtencoder/svgtenc/standalone/lib/SVGTBinEncode.exe
svgtencoder/svgtenc/standalone/lib/SYMDEFCPPDLL.dll
svgtencoder/svgtenc/standalone/lib/SYMDEFCPPDLL.lib
svgtencoder/svgtenc/standalone/lib/xerces-c_2.lib
svgtencoder/svgtenc/standalone/lib/xerces-c_2D.lib
svgtencoder/svgtenc/standalone/lib/xerces-c_2_6.dll
sysdef_1_4_0.dtd
systemDefinition.xml
systemDefinitionLayer.xml
toollibraries/group/bld.inf
uitools_plat/cdl_api/cdl_api.metaxml
uitools_plat/cdl_api/group/bld.inf
uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkInstance.h
uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkInterface.h
uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkProcess.h
uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkUtil.h
uitools_plat/cdl_api/inc/CdlDef.h
uitools_plat/group/bld.inf
uitools_plat/layout_system_private_api/group/bld.inf
uitools_plat/layout_system_private_api/inc/AknLayoutByteCodes.h
uitools_plat/layout_system_private_api/inc/AknLayoutConsts.h
uitools_plat/layout_system_private_api/layout_system_private_api.metaxml
uitools_pub/group/bld.inf
uitools_pub/third_party_bitmap_palette_api/group/bld.inf
uitools_pub/third_party_bitmap_palette_api/inc/ThirdPartyBitmap.pal
uitools_pub/third_party_bitmap_palette_api/third_party_bitmap_palette_api.metaxml
Binary file aknlayoutcompiler/binary/AknLayoutCompiler.exe has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/cdl/MasterLayoutPack.cdl	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,17 @@
+// MasterLayoutPack.cdl - Acts as a layout index for a whole layout DLL.
+
+Name: MasterLayoutPack
+Version: 1.0
+UID: 0x101feb1b
+
+%% C++
+
+#include <aknlayoutdef.h>
+#include <akndef.hrh>
+
+%% API
+
+TCdlArray<SCdlSize> sizes;
+TCdlArray<TAknLayoutId> variants;
+TCdlArray<TAknUiZoom> zooms;
+TCdlArray<TCdlArray<TCdlRef>*> contents;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/group/AknLayoutCompiler.mmp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET      AknLayoutCompiler.exe
+TARGETTYPE  EXE
+
+SYSTEMINCLUDE     .
+SYSTEMINCLUDE     ../inc
+SYSTEMINCLUDE   ../../inc
+SYSTEMINCLUDE   ../../inc/arabica
+
+MW_LAYER_SYSTEMINCLUDE
+
+// These options enable exception handling and set the warning level to 3 for command
+// line builds. STL code generates too many warnings at level 4, but is clean at
+// level 3. Also require RTTI.
+option MSVC /GX /W3 /GR
+
+SOURCEPATH      ../src
+
+source          CppWriter.cpp
+source          Extract.cpp
+source          HtmlParse.cpp
+source          Layout.cpp
+source          AknLayoutCompiler.cpp
+source          LayoutCompilerErr.cpp
+source          LayoutParse.cpp
+source          LayoutWriter.cpp
+source          WriterBase.cpp
+source          Lay2Cdl.cpp
+source          Cdl2Lag.cpp
+source          LayCdl2Inst.cpp
+source          LayCdlCheck.cpp
+source          LayoutPack.cpp
+source          LayCdl2InstO.cpp
+source          MakeLayConvTest.cpp
+source          LayScale.cpp
+source          AdaptationLayerTemplate.cpp
+source          Lay2LayPerf.cpp
+source          LayPerfWriter.cpp
+source			coreparser.cpp
+source			formulaparser.cpp
+source			formulatree.cpp
+
+#ifdef RD_XML_PARSER_TOOLCHAIN
+source          SaxErrorHandler.cpp
+source          MLCompData.cpp
+source          MLCompDataParse.cpp
+source          MLCompData2Cdl.cpp
+source          MLCompCdl2InstO.cpp
+source          MLAttributes.cpp
+source          MLAttributesParse.cpp
+source          MLCompData2LayPerf.cpp
+source          MLCompDataLayPerfWriter.cpp
+source          MLEqCompData.cpp
+source          MLEqCompDataParse.cpp
+source          MLEqCompData2DHuiML.cpp
+#endif
+
+source          ZoomLevelNames.cpp
+source          MasterLayoutPack.cpp
+
+#ifndef SBSV2
+  start CW32
+    win32_library /epoc32/release/cwtools/rel/CdlCompilerToolkit.lib
+  end
+
+  start VC32
+    win32_library /epoc32/release/tools/rel/CdlCompilerToolkit.lib
+  end
+#else 
+  START TOOLS
+    #if defined(CW32) 
+      win32_library /epoc32/release/cwtools/rel/CdlCompilerToolkit.lib
+    #elif defined(VC32)
+      win32_library /epoc32/release/tools/rel/CdlCompilerToolkit.lib
+    #endif
+  END
+#endif
+
+start TOOLS
+#ifdef RD_XML_PARSER_TOOLCHAIN
+win32_library /epoc32/release/tools/rel/Arabica.lib
+win32_library /epoc32/release/tools/rel/xerces-c_2.lib
+#endif
+win32_library Advapi32.lib 
+end
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  Build information file for project AknLayoutCompiler
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+TOOLS CWTOOLS
+
+PRJ_EXPORTS
+
+../binary/AknLayoutCompiler.exe /epoc32/tools/AknLayoutCompiler.exe
+
+PRJ_MMPFILES
+
+#if	defined(TOOLS) || defined(CWTOOLS)
+
+/*
+ * NOTICE! AknLayoutCompiler is not compiled any more during usual build.
+ * It is just exported from ../binary directory.
+ * If you really want compile AknLayoutCompiler from sources you need to 
+ * uncomment below line, build this project and copy 
+ * /epoc32/tools/AknLayoutCompiler.exe to ../binary directory and 
+ * put the binary to version control.
+ */
+// AknLayoutCompiler.mmp
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/AdaptationLayerTemplate.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef ADAPTATIONLAYERTEMPLATE_H
+#define ADAPTATIONLAYERTEMPLATE_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+
+class AdaptationLayerTemplate : public CCdlTkSourceFileWriter
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	~AdaptationLayerTemplate();
+
+private:
+	AdaptationLayerTemplate(TLayout& aLayout, CCdlTkInterface& aLayIface, CCdlTkInterface& aScaleIface, CCdlTkInstance& aInstance, string& aExisting);
+
+	CCdlTkInstance& Instance();
+	string FwdDeclName();
+	void Process();
+
+private:
+	void AddTableToInstance(TLayoutTable& aTable);
+	void AddLineToInstance(TLayoutLine& aLine);
+	bool HasApi(const string& aName);
+	CCdlTkImplementation& FindImp(const string& aName);
+	void SetFuncLine(CCdlTkImplementation& aImp, TLayoutLine& aLine);
+	pair<string,int> GetApiMatch(const string& aName);
+
+private:
+	CCdlTkInterface& iLayIface;
+	CCdlTkInterface& iScaleIface;
+	TLayout& iLayout;
+	CCdlTkInstance& iInstance;
+	string& iExisting;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Cdl2Lag.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef CDL2LAG_H
+#define CDL2LAG_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+using namespace std;
+
+/**
+*  CdlToLag
+*  Generates a LAG file macro API to access a CDL API
+*/
+class CdlToLag
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+private:
+	CdlToLag(ofstream& aLag, const string& aLagName);
+
+	void Start();
+	void AddInterface(CCdlTkInterface& aInterface);
+	void Finish();
+
+	void WriteHeader();
+	void WriteMacro(CCdlTkApi& aApi);
+	void WriteFooter();
+	void WriteInclude();
+
+private:
+	ofstream& iLag;
+	string iLagName;
+	CCdlTkInterface* iInterface;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/CodeGenConsts.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef CODEGENCONSTS_H
+#define CODEGENCONSTS_H
+
+#include <string>
+using namespace std;
+
+// includes
+const string KIncludeLayoutInstanceHeaderScalableDef("#include <aknlayout2scalabledef.h>");
+// directories
+const string KDirEpocSysHeader("\\epoc32\\include\\");
+const string KDirDomainSysHeader("\\epoc32\\include\\platform\\mw\\");
+
+// parameter namesy
+const string KParamNameBase("aIndex_");
+const string KParamNameB(KParamNameBase + "B");
+const string KParamNameL(KParamNameBase + "l");
+const string KParamNameR(KParamNameBase + "r");
+const string KParamNameNumberOfLinesShown("aNumberOfLinesShown");
+const string KParamParentRect("aParentRect");
+const string KParamLineIndex("aLineIndex");
+const string KParamComponentId("aComponentId");
+const string KParamOptionIndex("aVariety");
+const string KParamRowIndex("aRow");
+const string KParamColIndex("aCol");
+
+// types
+const string KTypeTextLineLayout("TAknTextLineLayout");
+const string KTypeWindowLineLayout("TAknWindowLineLayout");
+const string KTypeLayoutTableLimits("TAknLayoutTableLimits");
+const string KTypeMultiLineTextLayout("TAknMultiLineTextLayout");
+const string KTypeRect("const TRect&");
+const string KTypeInt("TInt");
+
+const string KTypeScreenComponentLayout("TAknScreenComponentLayout");
+const string KTypeContainerComponentLayout("TAknContainerComponentLayout");
+const string KTypePaneComponentLayout("TAknPaneComponentLayout");
+const string KTypeGraphicComponentLayout("TAknGraphicComponentLayout");
+
+const string KTypeWindowComponentLayout("TAknWindowComponentLayout");
+const string KTypeTextComponentLayout("TAknTextComponentLayout");
+const string KTypeComponentTableLimits("TAknComponentTableLimits");
+
+const string KTypeLayoutScalableTableLimits("TAknLayoutScalableTableLimits");
+const string KTypeLayoutScalableParameterLimits("TAknLayoutScalableParameterLimits");
+
+const string KTypeLayoutScalableComponentType("TAknLayoutScalableComponentType");
+
+// function names
+const string KFuncMultiline("Multiline_");
+const string KFuncLimitsSuffix("_Limits");
+const string KFuncParamLimitsSuffix("_ParamLimits");
+
+const string KFuncWindowLine("WindowLine");
+const string KFuncTextLine("TextLine");
+const string KFuncWindowTable("WindowTable");
+const string KFuncTextTable("TextTable");
+const string KFuncTableLimits("TableLimits");
+const string KFuncParamLimits("ParameterLimits");
+const string KFuncParamLimitsTable("ParameterLimitsTable");
+
+const string KFuncGetComponentTypeById("GetComponentTypeById");
+const string KFuncGetParamLimitsById("GetParamLimitsById");
+const string KFuncGetWindowComponentById("GetWindowComponentById");
+const string KFuncGetTextComponentById("GetTextComponentById");
+
+
+// zoom
+const string KDefaultZoomInstanceName("Normal");
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/CoreParser.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,125 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef COREPARSER_H
+#define COREPARSER_H
+
+#include <string>
+#include <vector>
+#include <deque>
+
+class Parser;
+
+class ParseResult
+	{
+public:
+	ParseResult();
+	static ParseResult Fail();
+
+	bool Matched() const;
+
+public:
+	int iRuleId;
+	int iStart;
+	int iEnd;
+	std::deque<ParseResult> iChildren;
+	};
+
+
+class Parser
+	{
+public:
+	Parser(const char* aMatch);
+	static Parser EOS();
+	static Parser Int();
+	static Parser Real();
+	static const Parser& Nul();
+
+	ParseResult Parse(const std::string& aString) const;
+
+	int Id() const;
+	void SetId(int aId);
+
+	Parser();
+	Parser(const Parser& aOther);
+	~Parser();
+	const Parser& operator=(const Parser& aOther);
+
+private:
+	friend Parser operator|(const Parser& aFirst, const Parser& aRest);
+	friend Parser operator>>(const Parser& aFirst, const Parser& aRest);
+	friend Parser operator*(const Parser& aSub);
+
+	enum T0Op
+		{
+		EExact,
+		EEos,
+		EInt,
+		EReal,
+		ENul,
+		ELast0
+		};
+	enum T1Op
+		{
+		EMult = ELast0,
+		ELast1
+		};
+	enum T2Op
+		{
+		ESeq = ELast1,
+		EAlt
+		};
+
+	Parser(T0Op aOp);
+	Parser(T1Op aOp, const Parser& aSub);
+	Parser(T2Op aOp, const Parser& aFirst, const Parser& aRest);
+
+	struct Step
+		{
+		Step(const Parser* aRule, int aPos, int aParent)
+			: iRule(aRule), iStep(0), iPos(aPos), iParent(aParent)
+			{
+			iResult.iStart = aPos;
+			}
+		const Parser* iRule;
+		int iStep;
+		ParseResult iResult;
+		int iPos;
+		int iParent;
+		};
+
+	enum TMatchRes
+		{
+		EFail,
+		EPass,
+		EContinue
+		};
+
+	TMatchRes ParseStep(int aStep, const std::string& aString, int aPos, std::vector<Step>& aStack) const;
+
+private:
+	int iOp;
+	const char* iMatch;
+	const Parser* iSub1;
+	const Parser* iSub2;
+	int iId;
+	};
+
+Parser operator|(const Parser& aFirst, const Parser& aRest);
+Parser operator>>(const Parser& aFirst, const Parser& aRest);
+//Parser operator*(const Parser& aSub);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/CppWriter.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef CPPWRITER_H
+#define CPPWRITER_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include "WriterBase.h"
+using namespace std;
+
+
+
+
+/**
+*  TValuesCppWriter
+*  Write out layout cell values for AknLayout.dll
+*/
+class TValuesCppWriter
+	{
+public:
+	TValuesCppWriter(TValues& aValues) : iValues(aValues) {}
+	void WriteCpp(ostream& aCpp);
+
+private:
+	TValues& iValues;
+	};
+
+
+/**
+*  TLayoutLineCppWriter
+*  Base class for writing out a layout line for AknLayout.dll
+*/
+class TLayoutLineCppWriter
+	{
+public:
+	TLayoutLineCppWriter(TLayoutLine& aLine) : iLine(aLine) {}
+	void WriteCpp(ostream& aCpp); 
+	virtual string Name()=0;
+	virtual void WriteMacro(ostream& aLag) = 0;
+	virtual void FillParamLists(vector<string>& aDef, vector<string>& aCtor) = 0;
+
+	void WriteCppData(ostream& aCpp);
+	int WriteParamList(ostream& aLag, const vector<string>& aParams);
+
+protected:
+	virtual void WriteLineClassName(ostream& aCpp) = 0;
+	virtual void WriteVarCppData(ostream& aCpp) = 0;
+	virtual void WriteFixedCppData(ostream& aCpp) = 0;
+
+	int ValCount();
+
+protected:
+	TLayoutLine& iLine;
+	};
+
+/**
+*  TWindowLineCppWriter 
+*  Write out a window line for AknLayout.dll
+*/
+class TWindowLineCppWriter : public TLayoutLineCppWriter
+	{
+public:
+	TWindowLineCppWriter(TLayoutLine& aLine) : TLayoutLineCppWriter(aLine) {}
+	void WriteMacro(ostream& aLag);
+	string Name();
+	void FillParamLists(vector<string>& aDef, vector<string>& aCtor);
+
+private:
+	void WriteVarCppData(ostream& aCpp);
+	void WriteFixedCppData(ostream& aCpp);
+	void WriteLineClassName(ostream& aCpp);
+	};
+
+/**
+*  TTextLineCppWriter 
+*  Write out a text line for AknLayout.dll
+*/
+class TTextLineCppWriter : public TLayoutLineCppWriter
+	{
+public:
+	TTextLineCppWriter(TLayoutLine& aLine) : TLayoutLineCppWriter(aLine) {}
+	void WriteMacro(ostream& aLag);
+	string Name();
+	void FillParamLists(vector<string>& aDef, vector<string>& aCtor);
+
+private:
+	void WriteVarCppData(ostream& aCpp);
+	void WriteFixedCppData(ostream& aCpp);
+	void WriteLineClassName(ostream& aCpp);
+
+	// Specific to text
+	void WriteMultiLineTextParamList(ostream& aLag, const vector<string>& aParams);
+
+private:
+	bool iBaseLineVariation;
+	};
+
+
+/**
+*  TLayoutTableCppWriter
+*  Write out a layout table for AknLayout.dll
+*/
+class TLayoutTableCppWriter
+	{
+public:
+	TLayoutTableCppWriter(TLayoutTable& aTable) : iTable(aTable) {}
+	void WriteCppLineData(ostream& aCpp);
+	void WriteCppTableData(ostream& aCpp);
+	void WriteLag(ostream& aLag);
+	void WriteLagSubTable(const TLayoutTable::TLayoutSubTable& aSubTable, int aCount, ostream& aLag);
+	static TLayoutLineCppWriter* CreateLayoutLineCppWriter(TLayoutLine& aData, TLayoutTable& iTable);
+
+private:
+	TLayoutTable& iTable;
+	};
+
+
+/**
+*  TLayoutCppWriter
+*  Write out a layout for AknLayout.dll
+*/
+class TLayoutCppWriter
+	{
+public:
+	TLayoutCppWriter(TLayout& aLayout) : iLayout(aLayout) {}
+	void WriteCppLineData(ostream& aCpp);
+	void WriteCppTableData(ostream& aCpp);
+	void WriteLag(ostream& aLag);
+
+private:
+	TLayout& iLayout;
+	};
+
+
+/**
+*  TLayoutLineTable 
+*  Represents and writes a table of layout lines for AknLayout.dll
+*/
+class TLayoutLineTable : public vector<TLayoutLine*>
+	{
+public:
+	void WriteCpp(ostream& aCpp);
+	void WriteLag(ostream& aLag);
+	};
+
+
+/**
+*  TCppWriter 
+*  Write the source code for AknLayout.dll
+*/
+class TCppWriter : public TLayWriterBase
+	{
+public:
+	TCppWriter(TLayout& aLayout, const std::string& aName);
+	void Write(const std::string& aLayName);
+
+private:
+	void Output(const string& aCpp, const string& aLag, const string& aLayName);
+
+	void WriteCppHeader(ostream& aCpp);
+	void WriteCppFooter(ostream& aCpp, const string& aLayName);
+	void WriteLagHeader(ostream& aLag);
+
+	void BuildLayoutLineTable();
+
+private:
+	TLayoutLineTable iLineTable;
+	string iShortName;
+	};
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Extract.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef EXTRACT_H
+#define EXTRACT_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+using namespace std;
+
+/**
+*  LayoutExtract
+*  Layout compiler process for extracting a layout from an HTML file
+*/
+class LayoutExtract
+	{
+public:
+	int Extract(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+private:
+	void ParseArgs(const vector<string>& args);
+
+private:
+	string iDocName;
+	string iLayoutName;
+	string iMergeName;
+	};
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/FormulaParser.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* 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 "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:
+*
+*/
+
+#ifndef FORMULA_PARSER_H
+#define FORMULA_PARSER_H
+
+#include <string>
+#include <vector>
+#include "coreParser.h"
+using namespace std;
+
+enum TFormulaParserIds
+	{
+	cell_name_ParserId=1,
+	parent_ParserId,
+	parent_cell_ParserId,
+	table_cell_ParserId,
+	comp_cell_ParserId,
+	abs_cell_ParserId,
+	units_ParserId,
+	constant_ParserId,
+	attribute_ParserId,
+	mystery_ParserId,
+	func_ParserId,
+	group_ParserId,
+	term_ParserId,
+	expression_ParserId,
+	comp_group_ParserId,
+	comp_ParserId,
+	conditional_ParserId,
+	};
+
+ParseResult ParseFormula(const string& aFormula);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/FormulaTree.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,83 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef FORMULATREE_H
+#define FORMULATREE_H
+
+#include <string>
+#include <vector>
+using namespace std;
+
+class ParseResult;
+
+class FormulaTreeNode
+	{
+public:
+	enum TNodeType
+		{
+		EReal=1,		// Real() = the number
+		EInt,			// Int() = the number
+		ECell,			// Char() = cell name
+		EParent,		// nothing special
+		EParentCell,	// Char() = parent cell name
+		ETableCell,		// Real() = target table
+		EComponent,		// Real() = component id, [0] = cell name
+		EAbsolute,		// Text() = whole thing, [0], [1] = real components, [2] = cell name
+		EUnits,			// Real() = units
+		EConstant,		// Real() = constant
+		EAttribute,		// Int() = attribute
+		EMystery,		// Text() = whole thing, [0], [1] = int components
+		EFunction,		// Text() = function name, [0] = parameter
+		EArithmetic,	// Char() = arithmetic operator, [0], [1] = sub expressions
+		ECondition,		// Text() = comparison operator, [0], [1] = sub expressions
+		EConditional	// no content, [0] = condition, [1] = then expression, [2] = else expression
+		};
+
+public:
+	static FormulaTreeNode* Parse(const string& aFormula);
+	virtual ~FormulaTreeNode();
+
+	int Size() const;
+	FormulaTreeNode& operator[](int aIndex);
+	const FormulaTreeNode& operator[](int aIndex) const;
+	
+	TNodeType Type() const;
+
+	string Text() const;
+	char Char() const;
+	int Int() const;
+	double Real() const;
+
+	FormulaTreeNode(const FormulaTreeNode& aOther);
+	static void Print(const FormulaTreeNode& aNode);
+
+private:
+	FormulaTreeNode(TNodeType aType, const string& aSource, int aStart, int aLen);
+	static FormulaTreeNode* NewTree(const ParseResult& aParse, const string& aFormula);
+	const FormulaTreeNode& operator=(const FormulaTreeNode& aOther);
+
+public:
+	vector<FormulaTreeNode*> iSubNodes;
+
+private:
+	const string& iSource;
+	int iStart;
+	int iLen;
+	TNodeType iType;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/HtmlParse.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef HTMLPARSE_H
+#define HTMLPARSE_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include <iosfwd>
+#include <vector>
+#include <string>
+#include "layout.h"
+using namespace std;
+
+/**
+*  THtmlParseLayoutTable 
+*  Parse a layout table from an HTML version of a LAF spec
+*/
+class THtmlParseLayoutTable : public TLayoutTable
+	{
+private:
+	typedef vector<string> Row;
+
+public:
+	THtmlParseLayoutTable(TLayout* aTables);
+	~THtmlParseLayoutTable();
+
+	bool Read(istream& in);
+
+private:
+	bool SearchForTableStart();
+	void ExtractTitle(const string& aText);
+	void ExtractTable();
+
+	string Next();
+	bool IsToken(const string& aText);
+	void PutBack(const string& aText);
+	char Get();
+	void PutBack(char aChar);
+	bool Eof();
+	
+	int GetVal(const string& aText, const string& aField);
+
+	bool IsWindowTable();
+	bool IsTextTable();
+
+	string StripTo(const string& aText, const string& aValid);
+	string UnHtml(const string& aText);
+	char HtmlChar(const string& aText);
+	string CleanMultiCell(const string& aText);
+	Row MakeParamTable(const Row& row, int start, int num);
+	string ConvertToAknName(const string& aText);
+	string SplitMultiCell(const string& aCell, const string& aValid);
+	string CleanCell(const string& cell, const Row& row);
+
+	void AddRow(Row& row);
+	void AddColumnNameRow(Row& row);
+	void AddLineRow(const Row& row);
+	void AddTitleRow(const Row& row);
+
+private:
+	istream* iIn;
+	string iPutBack;
+	};
+
+
+/**
+*  THtmlParseLayout 
+*  Parse the entire layout from an HTML version of a LAF spec
+*/
+class THtmlParseLayout : public TLayout
+	{
+public:
+	void Parse(istream &aIn);
+	};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Lay2Cdl.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAY2CDL_H
+#define LAY2CDL_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  LayoutToCdl
+*  Generate a CDL interface for a layout
+*/
+class LayoutToCdl
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	static auto_ptr<CCdlTkInterface> LayoutToInterface(const TLayout& aLayout);
+	static void AddTableToInterface(CCdlTkInterface& aInterface, TLayoutTable& aTable);
+	static void AddWindowLineToInterface(CCdlTkInterface& aInterface, TLayoutLine& aLine);
+	static void AddTextLineToInterface(CCdlTkInterface& aInterface, TLayoutLine& aLine);
+	static string TableApiName(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum);
+	static string LineApiName(TLayoutLine& aLine);
+	static void AddTableLimitsToInterface(CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum);
+	static void AddSubTableToInterface(const string& aType, CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum);
+	static void AddParamsToFunc(TLayoutLine& aLine, CCdlTkFunctionApi& aFunc);
+	static string InterfaceName(const string& aFileName);
+	static void SetHeaders(CCdlTkInterface& aInterface, const string& aCdlName, int aUid);
+private:
+	static CCdlTkApi* CreateGenericApi(CCdlTkInterface& aInterface, TLayoutLine& aLine);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Lay2LayPerf.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAY2LAYPERF_H
+#define LAY2LAYPERF_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  LayoutToLayPerf
+*  Compiler mode for rescaling a layout
+*/
+class LayoutToLayPerf
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	static string InterfaceName(const string& aFileName);
+
+private:
+	LayoutToLayPerf(const string& aCdlName, TLayout& aSourceLayout, const string& aDestLayoutName);
+	void WriteLayout();
+
+private:
+	TLayout& iLayout;
+	string iDestLayoutName;
+	string iCdlName;
+	};
+
+
+#endif // LAY2LAYPERF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Lay2MLInst.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* 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 "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:
+*
+*/
+
+#ifndef LAY2MLINST_H
+#define LAY2MLINST_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+#include "MLInst.h"
+
+using namespace std;
+
+class LayoutToMLInst
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	static string InterfaceName(const string& aFileName);
+	static auto_ptr<TMLInst> LayoutToInst(const TLayout& aLayout);
+	static void AddTableToInst(TMLInst& aInst, TLayoutTable& aTable);
+	static void AddWindowLineToInstTable(TMLInstTable& aInstTable, TLayoutLine& aLine);
+	static void AddTextLineToInstTable(TMLInstTable& aInstTable, TLayoutLine& aLine);
+	static void AddParamToLine(TMLInstLine& aInstLine, TValues& aValue);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayCdl2Inst.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYCDL2INST_H
+#define LAYCDL2INST_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  CLayoutToInst 
+*  Generate customisation instance for a set of layouts which use a particular CDL
+*  interface (unoptimised)
+*/
+class CLayoutToInst : public CCdlTkSourceFileWriter
+	{
+public:
+	CLayoutToInst(CLayoutToInst* aBase, CCdlTkInterface& aInterface, auto_ptr<TLayout>& aLayout, const string& aInstName);
+	~CLayoutToInst();
+
+	CCdlTkInstance& Instance();
+	string FwdDeclName();
+	void Process();
+
+private:
+	void AddTableToInstance(TLayoutTable& aTable);
+	void AddWindowLineToInstance(TLayoutLine& aLine);
+	void AddTextLineToInstance(TLayoutLine& aLine);
+	void AddTableLimitsToInstance(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aTableNum);
+	void AddSubTableToInstance(const string& aType, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aTableNum);
+	bool HasApi(const string& aName);
+	CCdlTkImplementation& FindImp(const string& aName);
+	void SetDataLine(CCdlTkImplementation& aImp, TLayoutLine& aLine, const string& aType, const string aOutputOrder[], int aOutputOrderSize);
+	void SetFuncLine(CCdlTkImplementation& aImp, TLayoutLine& aLine, const string& aType, const string aOutputOrder[], int aOutputOrderSize, const string& aPreExtra, const string& aPostExtra);
+	void MirrorParamNames(std::string& aNames);
+	void AddFwdRefToInstance(const string& aName, bool aCast);
+
+private:
+	CLayoutToInst* iBase;
+	CCdlTkInterface& iInterface;
+	TLayout* iLayoutPtr;
+	TLayout& iLayout;
+	CCdlTkInstance* iInstance;
+	std::string iInstName;
+	};
+
+class LayoutAndCdlToCdlInstance
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	static void CheckLayoutAgainstInterface(const TLayout& aLayout, const CCdlTkInterface& aIface);
+
+	LayoutAndCdlToCdlInstance(CCdlTkInterface& aInterface);
+	~LayoutAndCdlToCdlInstance();
+
+	void AddLayout(auto_ptr<TLayout>& aLayout, const string& aInstName);
+	void WriteInstances();
+
+private:
+	typedef vector<CLayoutToInst*> CLayouts;
+	CLayouts iLayouts;
+	CCdlTkInterface& iInterface;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayCdl2InstO.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYCDL2INSTO_H
+#define LAYCDL2INSTO_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+class CLayoutInstOpt;
+class CLayoutInstOptImpl;
+typedef vector<CLayoutInstOptImpl*> CLayoutInstOptImpls;
+
+/**
+*  SImplFunc
+*  This class represents a layout data decompression function local to a layout instance.
+*  These functions will call the corresponding DLL wide function for decompression.
+*/
+struct SImplFunc
+	{
+	enum TFuncType
+		{ 
+		EWindowLine, 
+		ETextLine,
+		EMultilineTextLine,
+		ETableLimits,
+		EWindowTable, 
+		ETextTable
+		};
+	TFuncType iType;
+	int iParams;
+	bool iParent;
+	string iDefn;
+	string iPtrRef;
+
+	SImplFunc(TFuncType aType, int aParams, bool aParent, string aDefn, string aPtrRef)
+	: iType(aType), iParams(aParams), iParent(aParent), iDefn(aDefn), iPtrRef(aPtrRef)
+		{}
+	};
+
+
+/**
+*  CAllFuncs
+*  This represents a collection of all the SImplFunc objects that a layout instance may need
+*/
+class CAllFuncs : public vector<SImplFunc>
+	{
+public:
+	CAllFuncs(int aMaxParams);
+
+private:
+	void AddLineFunc(SImplFunc::TFuncType aType, int aParams, bool aParent, const string& aReturn, const string& aFuncName);
+	void AddTableFunc(SImplFunc::TFuncType aType, int aParams, bool aParent, const string& aReturn, const string& aFuncName);
+	};
+
+
+class CInstanceList
+	{
+public:
+	// ProcessOptions will remove "-i<instanceListFile>" from aArgs, if it appears at position [2].
+	void ProcessOptions(vector<string>& aArgs);
+	bool IsInstanceOk(const string& aInstance) const;
+private:
+	set<string> iInstances;
+	bool iLoaded;
+	};
+
+/**
+*  LayoutCdlInstanceOpt
+*  Generate a set of optimised layout instances for a number of layouts with a common
+*  CDL interface
+*/
+class LayoutCdlInstanceOpt
+	{
+private:
+	typedef vector<CLayoutInstOpt*> CLayouts;
+
+public:
+	static int Process(vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	CCdlTkInterface& Interface();
+	CLayouts& Layouts();
+	CLayoutInstOptImpl* FindSimilarImpl(TLayoutLine& aLine);
+	int FindSimilarBytes(CLayoutInstOptImpl* aImpl);
+	void AddImpl(CLayoutInstOptImpl* aImpl);
+
+private:
+	LayoutCdlInstanceOpt(CCdlTkInterface& aIface);
+	~LayoutCdlInstanceOpt();
+
+	void AddLayout(auto_ptr<TLayout>& aLayout, const string& aInstName);
+	void Process();
+	void WriteInstances();
+	void ProcessCommonImpl();
+	bool LinesAreEqual(TLayoutLine& aLine1, TLayoutLine& aLine2);
+
+private:
+	CLayouts iLayouts;
+	CCdlTkInterface& iInterface;
+	CLayoutInstOptImpls iImpls;
+	int iByteCodeIndex;
+	vector<char> iBytesAggregated;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayCdlCheck.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYCDLCHECK_H
+#define LAYCDLCHECK_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+/**
+*  LayCdlCheck
+*  Check the interface which could be use with a layout against one specified in a CDL file
+*/
+class LayCdlCheck
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	LayCdlCheck(TLayout& aLayout, CCdlTkInterface& aInterface, CCdlTkInterface& aExcluded, const string& aOpt);
+	~LayCdlCheck();
+	void Process();
+
+	void Compare(vector<string>& aGood, vector<string>& aOnlyLay, vector<string>& aOnlyCdl, vector<string>& aParamMismatch);
+	void Report(const string& aTitle, vector<string>& aApi);
+	bool HasOpt(char c);
+
+private:
+	TLayout& iLayout;
+	CCdlTkInterface& iInterface;
+	CCdlTkInterface& iExcluded;
+	CCdlTkInterface* iLayoutInterface;	// owned
+	string iOpt;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayPerfWriter.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYPERFWRITER_H
+#define LAYPERFWRITER_H
+
+#include "WriterBase.h"
+
+/**
+*  TLayPerfTableWriter
+*  Writes a layout table in .lay format
+*/
+class TLayPerfTableWriter
+	{
+public:
+	TLayPerfTableWriter(TLayoutTable& aTable, string& aInterfaceName, int aTableId);
+	~TLayPerfTableWriter();
+
+	void Write(ostream& out);
+	static void WriteCell(ostream& out, TValues& values);
+
+private:
+	bool IsWindowTable();
+	void WriteWindowTable(ostream& out);
+	void WriteWindowLine(ostream& out, TLayoutLine& line);
+	void BuildGenericLine(TLayoutLine& aLine, const string* aKParams, int aCount, string& aParams, string& aLimits);
+	bool IsTextTable();
+	void WriteTextTable(ostream& out);
+	void WriteTextLine(ostream& out, TLayoutLine& line);
+
+private:
+	TLayoutTable& iTable;
+	string iInterfaceName;
+	int iTableId;
+	};
+
+/**
+*  TLayPerfWriter 
+*  Writes a layout in .lay format
+*/
+class TLayPerfWriter : public TLayWriterBase
+	{
+public:
+	TLayPerfWriter(TLayout& aLayout, const std::string& aName);
+	void Write(const std::string& aLayName);
+	};
+
+#endif // LAYPERFWRITER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayScale.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYSCALE_H
+#define LAYSCALE_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  LayoutScale
+*  Compiler mode for rescaling a layout
+*/
+class LayoutScale
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+private:
+	LayoutScale(TLayout& aSourceLayout, int aSourceWidth, int aSourceHeight, const string& aDestLayoutName, int aDestWidth, int aDestHeight);
+	void Run();
+	void RescaleLayout();
+	void WriteLayout();
+
+private:
+	enum TScale {EHoriz, EVert};
+	void RescaleValue(string& aVal, TScale aDir);
+	string RescaleNum(string& aNum, TScale aDir);
+    void TagScaledToken(string& aToken);
+	int Scale(int aNumber, int aNumerator, int aDenominator);
+
+private:
+	TLayout& iLayout;
+	int iSourceWidth;
+	int iSourceHeight;
+	const string& iDestLayoutName;
+	int iDestWidth;
+	int iDestHeight;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Layout.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+#ifndef LAYOUT_H
+#define LAYOUT_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <map>
+
+using namespace std;
+
+class TLayoutLine;
+class TLayoutTable;
+class TLayout;
+
+extern const string KWindowOutputOrder[];
+extern const string KTextOutputOrder[];
+extern const string KWindowOutputOrderMirrored[];
+extern const string KTextOutputOrderMirrored[];
+extern const int KWindowOutputOrderSize;
+extern const int KTextOutputOrderSize;
+
+
+/**
+*  TLayout 
+*  The core layout class - this represents a complete layout, 
+*  typically loaded from a .lay file
+*/
+class TLayout : public vector<TLayoutTable*>
+	{
+public:
+	enum TMergeMode	{ KMergeModeMerge, KMergeModeVariant, KMergeModeUnion };
+
+public:
+	TLayout();
+	TLayout(const TLayout& aOther);
+	TLayout& operator=(const TLayout& aOther);
+
+	virtual ~TLayout();
+	void Merge(TLayout::TMergeMode aMergeMode, TLayout& aLayout);
+	TLayoutLine* FindLine(const string& aName);
+	void Compile();
+
+public:
+	string iName;
+	bool iCanBeMirror;
+	};
+
+
+/**
+*  TValues 
+*  The values stored in a cell in a layout line
+*/
+class TValues : public vector<string>
+	{
+// This class is generic with respect to the type of line it is used by
+public:
+	TValues();
+	TValues(TLayoutLine* aLine, string aName);
+
+	bool operator==(const TValues& aOther) const;
+
+	void Merge(TValues& aValues);
+	void Compile();
+	string ParamName() const;
+	static string CppValue(const string& aValue);
+
+public:
+	TLayoutLine* iLine;
+	string iName;
+	string iParam;
+	bool iNeedsP;
+	bool iNeedsIndex;
+	};
+
+
+/**
+*  TLayoutLine 
+*  A layout line
+*/
+class TLayoutLine : public map<string, TValues>
+	{
+public:
+	TLayoutLine(TLayoutTable* aTable, int aId);
+	TLayoutLine(TLayoutTable* aTable, const TLayoutLine& aOther);
+
+	bool operator==(const TLayoutLine& aOther) const;
+	bool ValuesEqual(const TLayoutLine& aOther) const;
+
+	void Merge(TLayout::TMergeMode aMergeMode, TLayoutLine& aLine);
+	void Compile();
+	string Name() const;					
+	string TableName() const;
+	bool MatchParams(const TLayoutLine& aLine) const;
+	bool NeedsParams() const { return iNeedsP || iNeedsIndex; }
+
+	void WarnMergeMismatch(TLayoutLine& aLine);
+
+public:
+	int iId;
+	TLayoutTable* iTable;
+	bool iNeedsP;
+	bool iNeedsIndex;
+	bool iIsUnique;
+	int iGlobalIndex;
+	bool iIsMirroredHorizontally; // i.e. l and r are swapped
+	bool iIsMergedIdentical;
+	};
+
+
+/**
+*  TLayoutTable 
+*  A layout table
+*/
+class TLayoutTable : public vector<TLayoutLine*>
+	{
+public:
+	enum TTableType { EUnknownTable, EWindowTable, ETextTable };
+	class TLayoutSubTable : public vector<int>
+		{
+	public:
+		TLayoutSubTable();
+		bool iIsMergedIdentical;
+		};
+	typedef vector<TLayoutSubTable*> TLayoutSubTables;
+
+public:
+	TLayoutTable(TLayout* aTables);
+	TLayoutTable(TLayout* aTables, const TLayoutTable& aOther);
+	virtual ~TLayoutTable();
+
+	void Merge(TLayout::TMergeMode aMergeMode, TLayoutTable& aTable);
+	TLayoutLine* FindLine(const string& aName);
+	void Compile();
+	void BuildSubTables();
+	void DestroySubTables();
+	string Name();
+	static bool IsValueColumn(string aName);
+	static bool IsNumericColumn(string aName);
+	void SetDefaultColumnNames();
+	bool IsWorthATableIndex();
+
+public:
+	TLayoutSubTables iSubTables;
+	vector<string> iColumnNames;
+	TTableType iType;
+	TLayout* iTables;
+	string iName;
+	TLayoutLine* iParent;
+	string iParentName;
+	bool iNeedsP;
+	bool iNeedsIndex;
+	int iFirstLineGlobalIndex;
+	bool iAppend;
+	bool iNoSubTables;
+	};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayoutCompilerErr.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+#ifndef LAYOUTCOMPILERERR_H
+#define LAYOUTCOMPILERERR_H
+
+#include <iosfwd>
+#include <string>
+#include <cdlcompilertoolkit/cdltkutil.h>
+using namespace CdlCompilerToolkit;
+using namespace std;
+
+/**
+*  LayoutCompilerErr 
+*  Base class for exceptions in the layout compiler
+*/
+class LayoutCompilerErr : public CdlCompilerToolkitErr
+	{};
+
+/**
+*  NotFoundErr 
+*  A "not found" exception, which takes a string to explain what was not found
+*/
+class NotFoundErr : public LayoutCompilerErr
+	{
+public:
+	NotFoundErr(const string& aName) : iName(aName) {}
+	void Show(ostream& stream) const;
+private:
+	string iName;
+	};
+
+/**
+*  GeneralErr 
+*  A general compiler error, which takes a string to explain what the error was
+*/
+class GeneralErr : public LayoutCompilerErr
+	{
+public:
+	GeneralErr(const string& aMessage) : iMessage(aMessage) {}
+	void Show(ostream& stream) const;
+private:
+	string iMessage;
+	};
+
+string StreamLoc(const istream& stream, const string& msg, int before, int after);
+
+
+/**
+*  LayoutProcessArgsErr
+*  A templated exception class that indicated an exception in the command line parameter
+*  processing in the class in which it is instantiated on.
+*/
+template<class T>
+class LayoutProcessArgsErr : public LayoutCompilerErr
+	{
+	void Show(ostream& aStream) const { T::ShowHelp(aStream); }
+	};
+
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayoutConfig.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,91 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef LAYOUTCONFIG_H
+#define LAYOUTCONFIG_H
+
+#include <set>
+#include <string>
+#include <iosfwd>
+#include <vector>
+
+class LayoutConfig
+	{
+public:
+	class Size
+		{
+	public:
+		enum TOrientation { EPortrait, ELandscape, ESquare };
+	public:
+		Size();
+		TOrientation Orientation() const;
+		bool operator>(const Size& aRhs) const;
+	public:
+		int iWidth;
+		int iHeight;
+		};
+	typedef std::set<Size, std::greater<Size> > Sizes;
+
+	enum TTarget { EPlatform, EProduct };
+	enum TLegacyMode { ENoLegacyMode, ELegacyMode };
+
+public:
+	static int Process(const std::vector<std::string>& args);
+	static void ShowHelp(std::ostream& stream);
+
+	~LayoutConfig();
+
+protected:
+	LayoutConfig();
+
+	void ParseArgs(const std::vector<std::string>& args);
+	void ParseOpt(const std::string& opt);
+
+	void SetFlags(TTarget aTarget, TLegacyMode aLegacyMode);
+
+	const Sizes& AllSizes() const;
+	const Sizes& ConfiguredSizes() const;
+	const Sizes& SizesForTarget() const;
+
+//	static int TestLayoutConfig();
+
+private: // to be overridden
+	virtual int Process() = 0;
+
+private:
+	void LoadAllSizes();
+	void LoadConfiguredSizes();
+	void OpenBldCfg(std::ifstream& aBldCfg);
+	bool ParseSize(const std::string& aLine, Size& aSize) const;
+
+private:
+	Sizes iAll;
+	Sizes iConf;
+	TTarget iTarget;
+	TLegacyMode iLegacyMode;
+	std::string iTargetFileName;
+	std::string iBaseFileName;
+	};
+
+
+class WsiniConfig : public LayoutConfig
+	{
+private: // from LayoutConfig
+	virtual int Process();
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayoutPack.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYOUTPACK_H
+#define LAYOUTPACK_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+/**
+*  LayoutPackage
+*  Write a layout package according to the LayoutPack.cdl interface
+*/
+class LayoutPackage
+	{
+public:
+	static int Process(vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+private:
+	static void Process(
+		const string& aName, 
+		const string& aWidth, 
+		const string& aHeight, 
+		const string& aId, 
+		const string& aStyleName,
+		const string& aDeliveryTypeName,
+        const string& aPriority,
+        const string& aAppUid,
+		vector<string>::const_iterator aBegin, 
+		vector<string>::const_iterator aEnd, 
+		const string& aZoomName);
+	static void Implement(
+		CCdlTkPackage& aPkg, 
+		const string& aApi, 
+		const string& aTarget, 
+		const string& aReplace,
+		const string& aComment = "");
+	static void ProcessOptionalStringArg(vector<string>& args, const string& aOption, string& aArg);
+	static string Hash(const string& aString);
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayoutParse.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYOUTPARSE_H
+#define LAYOUTPARSE_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include "LayoutCompilerErr.h"
+#include "Layout.h"
+using namespace std;
+
+
+/**
+*  LayParseErr 
+*  An exception class for .lay file parsing errors
+*/
+class LayParseErr : public LayoutCompilerErr
+	{
+public:
+	LayParseErr(istream& aIn, const string& aTok, const string& aMsg);
+	void Show(ostream& aOut) const;
+private:
+	string iLoc;
+	string iTok;
+	string iMsg;
+	};
+
+
+/**
+*  TLayParseValues 
+*  Parse the values in a layout cell from .lay format
+*/
+class TLayParseValues : public TValues
+	{
+// This class is generic with respect to the type of line it is used by
+public:
+	TLayParseValues(TLayoutLine* aLine, string aName);
+	void Parse(istream& aIn);
+	};
+
+
+/**
+*  TLayParseLayoutLine
+*  Abstract class for common line parsing functionality
+*/
+class TLayParseLayoutLine : public TLayoutLine
+	{
+public:
+	TLayParseLayoutLine(TLayoutTable* aTable, int aId);
+	void Parse(istream& aIn);
+	};
+
+
+/**
+*  TLayParseLayoutTable 
+*  Parse a layout table in .lay format
+*/
+class TLayParseLayoutTable : public TLayoutTable
+	{
+public:
+	TLayParseLayoutTable(TLayout* aTables);
+	virtual void Parse(istream& aIn);
+	};
+
+
+/**
+*  TLayParseLayout 
+*  Parse a layout file in .lay format
+*/
+class TLayParseLayout : public TLayout
+	{
+public:
+	static auto_ptr<TLayParseLayout> Parse(const string& aLayName);
+	void Parse(istream& aIn);
+	};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/LayoutWriter.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef LAYOUTWRITER_H
+#define LAYOUTWRITER_H
+
+#include "WriterBase.h"
+
+/**
+*  TLayoutTableWriter
+*  Writes a layout table in .lay format
+*/
+class TLayoutTableWriter
+	{
+public:
+	TLayoutTableWriter(TLayoutTable& aTable);
+	~TLayoutTableWriter();
+
+	void Write(ostream& out);
+	static void WriteCell(ostream& out, TValues& values);
+
+private:
+	bool IsWindowTable();
+	void WriteWindowTable(ostream& out);
+	void WriteWindowLine(ostream& out, TLayoutLine& line);
+	bool IsTextTable();
+	void WriteTextTable(ostream& out);
+	void WriteTextLine(ostream& out, TLayoutLine& line);
+
+private:
+	TLayoutTable& iTable;
+	};
+
+/**
+*  TLayoutWriter 
+*  Writes a layout in .lay format
+*/
+class TLayoutWriter : public TLayWriterBase
+	{
+public:
+	TLayoutWriter(TLayout& aLayout, const std::string& aName);
+	void Write(const std::string& aLayName);
+	};
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLAttributes.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MLATTRIBUTES_H
+#define MLATTRIBUTES_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated"
+#pragma warning (disable:4503)
+
+
+#include <string>
+#include <iosfwd>
+#include <map>
+
+using namespace std;
+
+class TMLAttributes;
+
+/**
+*  TMLAttributeSet
+*  The attributes stored in an attribute set
+*/
+typedef map<int, string> TMLAttributeZoomLevels;
+class TMLAttributeSet : public map<int, TMLAttributeZoomLevels>
+	{
+public: // constructors, operators, etc
+	TMLAttributeSet();
+	TMLAttributeSet(TMLAttributes* aAttributes);
+	virtual ~TMLAttributeSet();
+public: // new methods
+	void Merge(TMLAttributeSet& aOther);
+	void Compile();
+public: // member data, not owned
+	TMLAttributes* iAttributes;
+	};
+
+/**
+*  TMLAttributes
+*  The attribute values stored in a layout component
+*/
+typedef map<string, TMLAttributeSet*> TMLAttributeSetComponent;
+class TMLAttributes: public map<int, TMLAttributeSetComponent>
+	{
+public:
+	typedef map<string, int> TMLAttributeNames;
+public: // constructors, operators, etc
+	TMLAttributes();
+	virtual ~TMLAttributes();
+public: // new methods
+	void Merge(TMLAttributes& aOther);
+	void Compile();
+public: // member data, owned
+	string iName;
+	string iTimestamp;
+	bool iCanBeMirror;
+	TMLAttributeNames iNames;
+	};
+
+#endif // MLATTRIBUTES_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLAttributesParse.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#ifndef MLATTRIBUTESPARSE_H
+#define MLATTRIBUTESPARSE_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayoutCompilerErr.h"
+#include "MLAttributes.h"
+
+#include <avkon.hrh> // for logical font ids
+
+#include "SaxErrorHandler.h"
+
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <stack>
+
+using namespace std;
+
+
+//
+// defines
+//
+
+/**
+ * this is the interface to the SAX handler
+ */
+class MSaxLayoutAttributesHandler
+	{
+public:
+	typedef SAX::basic_Attributes<std::string> TAttribs; // this is XML Attribs, not to be confused with layout attibutes!
+	virtual MSaxLayoutAttributesHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs) { return this; };
+	virtual void HandleSaxEnd(const std::string& aElement) { };
+	};
+
+
+/**
+ * this corresponds to an attribute set in the xml
+ */
+class TMLAttributeSetParse : public TMLAttributeSet, public MSaxLayoutAttributesHandler
+	{
+public:
+	TMLAttributeSetParse(TMLAttributes* aAttributes);
+public: // from MSaxLayoutHandler
+	MSaxLayoutAttributesHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxEnd(const std::string& aElement);
+public: // new methods
+	int CompId() const;
+	string Name() const;
+private:
+	void HandleSaxAttribute(const TAttribs& aAttribs);
+	void HandleSaxCalc(const TAttribs& aAttribs);
+private:
+	int iId;
+	int iCompId;
+	string iName;
+	TMLAttributeZoomLevels* iSaxZoomLevels;
+	};
+
+/**
+ *  this corresponds to attributes in the xml
+ */
+class TMLAttributesParse : public TMLAttributes, public MSaxLayoutAttributesHandler
+	{
+public:
+	static auto_ptr<TMLAttributesParse> Parse(const string& aLayName);
+	TMLAttributesParse();
+public: // from MSaxLayoutHandler
+	MSaxLayoutAttributesHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxEnd(const std::string& aElement);
+private: // owned
+	TMLAttributeSetParse* iSaxAttributeSet;
+	};
+
+/**
+ * this is the main SAX parser implementation
+ */
+class TLayoutAttributesSaxParser : private SAX::basic_DefaultHandler<std::string>
+	{
+private:
+	typedef stack<MSaxLayoutAttributesHandler*> TSaxAttributesHandlerStack;
+	typedef SAX::basic_ErrorHandler<std::string>::SAXParseExceptionT TException;
+
+public:
+	TLayoutAttributesSaxParser(MSaxLayoutAttributesHandler* aHandler);
+	void Parse(const std::string& aFileName);
+
+private: // from basic_DefaultHandler
+	void startElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName, const SAX::basic_Attributes<std::string>& atts);
+	void endElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName);
+
+	void warning(const TException& aException);
+	void error(const TException& aException);
+	void fatalError(const TException& aException);
+
+private:
+	TSaxAttributesHandlerStack iStack;	// stack content not owned
+	};
+
+
+#endif // MLATTRIBUTESPARSE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompCdl2InstO.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MLCOMPCDL2INSTO_H
+#define MLCOMPCDL2INSTO_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "MLCompData.h"
+#include "MLAttributes.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+// forward declares and typedefs
+class CInstanceList;
+class CMLCompDataInstOpt;
+class CMLCompDataInstOptImpl;
+typedef vector<CMLCompDataInstOptImpl*> CMLCompDataInstOptImpls;
+class CZoomLevelNames;
+
+/**
+*  MLCompDataCdlInstanceOpt
+*  Generate a set of optimised layout instances for a number of layouts with a common
+*  CDL interface
+*/
+class MLCompDataCdlInstanceOpt
+	{
+private:
+	struct InstStruct
+		{
+		InstStruct(string aInstName, TMLCompData* aInst, TMLAttributes* aAttribs);
+		string iInstName;
+		TMLCompData* iInst;
+		TMLAttributes* iAttribs;
+		};
+
+	class InstList : public vector<InstStruct>
+		{
+	public:
+		~InstList();
+		};
+
+	typedef vector<TMLCompData*> CCompDataLayouts;
+	typedef vector<CMLCompDataInstOpt*> CCompDatas;
+	typedef map<int, CCompDatas> CCompDataZoomLevelDatas;
+public:
+	static int Process(vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+public:
+	CCdlTkInterface& Interface();
+	int FindSimilarBytes(CMLCompDataInstOptImpl* aImpl, int aBaseOffset);
+	void AddImpl(CMLCompDataInstOptImpl* aImpl);
+	void ResizeByteStream(int aSize);
+	int ByteStreamSize() const;
+
+
+private:
+	static void ProcessSeparators(vector<string>& args, vector<int>& aSeparators);
+	static bool CheckForUsedInstances(const CInstanceList& aUsedList, const CZoomLevelNames& aZoomLevelNames, const vector<string>& aArgs, const vector<int>& aSeparators, int aSepIndex);
+	static void ParseInstances(const vector<string>& aArgs, const vector<int>& aSeparators, int aSepIndex, InstList& aInstList);
+	static void MergeLayouts(CInstanceList& aInstUsedList, CZoomLevelNames& aZoomLevelNames, const InstList& aInstances, InstList& aMergedLayouts);
+
+private:
+	MLCompDataCdlInstanceOpt(CCdlTkInterface& aIface);
+	~MLCompDataCdlInstanceOpt();
+
+	void AddInst(const InstStruct& aInstStruct, CZoomLevelNames& aZoomLevelNames, bool aAllParams, bool aNonRomDelivery);
+	void Process();
+	void WriteInstances();
+	void ProcessCommonImpl();
+
+private:
+	CCompDataLayouts iLayouts; // the comp datas are owned
+	CCompDataZoomLevelDatas iZoomLevelDatas; // the comp data inst opts are owned
+	CCdlTkInterface& iInterface; // not owned
+	CMLCompDataInstOptImpls iImpls; // not owned
+	vector<char> iBytesAggregated;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompData.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,367 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MLCOMPDATA_H
+#define MLCOMPDATA_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated"
+#pragma warning (disable:4503)
+
+#include "MLAttributes.h"
+
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <map>
+
+using namespace std;
+
+class TMLCompDataLine;
+class TMLCompDataTable;
+class TMLCompData;
+class TMLAttributes;
+
+extern const string KCompDataPaneOutputOrder[];
+extern const string KCompDataPaneOutputOrderMirrored[];
+extern const string KCompDataGraphicOutputOrder[];
+extern const string KCompDataGraphicOutputOrderMirrored[];
+extern const string KCompDataTextOutputOrder[];
+extern const string KCompDataTextOutputOrderMirrored[];
+extern const int KCompDataPaneOutputOrderSize;
+extern const int KCompDataGraphicOutputOrderSize;
+extern const int KCompDataTextOutputOrderSize;
+/**
+*  TMLCompDataCalcs
+*  The calcs stored in a value
+*/
+typedef map<int, string> TMLCompDataCalcs;
+typedef map<int, TMLCompDataCalcs> TMLCompDataZoomLevels;
+typedef map<int, TMLCompDataZoomLevels> TMLCompDataVarieties;
+
+/**
+*  TMLCompDataValues 
+*  The values stored in a cell in a layout line
+*/
+class TMLCompDataValues : public TMLCompDataVarieties
+	{
+public:
+	enum TCompDataCellType
+		{
+		ECellTypeDefault,
+		ECellTypeParamLimit,
+		ECellTypeCol,
+		ECellTypeRow
+		};
+
+public: // constructors, operators, etc
+	TMLCompDataValues();
+	TMLCompDataValues(TMLCompDataLine* aLine);
+	virtual ~TMLCompDataValues();
+	bool operator==(const TMLCompDataValues& aOther) const;
+
+public: // new methods
+    bool Merge(TMLCompDataLine* aLine, string aName, TMLCompDataValues& aOtherValues, bool aMirrorMerge);
+	void Compile(const string& aCellName);
+	static string CppValue(const string& aValue);
+	static string MirrorJustificationValue(const string& aValue);
+	static TCompDataCellType Type(string aName); 
+
+public: // member data
+	TMLCompDataLine* iLine; // not owned
+	string iName;
+	};
+
+
+//
+// Parent Info
+//
+
+/**
+*  TMLCompDataParentInfoSelector
+*
+*  The parent id and parent variety index for each variety index
+*/
+struct TMLCompDataParentInfoSelector
+	{
+public:
+	TMLCompDataParentInfoSelector();
+	TMLCompDataParentInfoSelector(int aParentId, int aParentVariety);
+public:
+	int iParentId;
+	int iParentVariety;
+	};
+
+typedef map<int, TMLCompDataParentInfoSelector> TMLCompDataParentInfoVarieties;
+
+/**
+*  TMLCompDataParentInfo
+*
+*  Contains the parent info selector for each variety index
+*/
+class TMLCompDataParentInfo : public TMLCompDataParentInfoVarieties
+	{
+public: // constructors etc
+	TMLCompDataParentInfo();
+	TMLCompDataParentInfo(TMLCompDataLine* aLine);
+	virtual ~TMLCompDataParentInfo();
+public: // new methods
+	void Merge(const TMLCompDataParentInfo& aOther);
+public: // member data
+	TMLCompDataLine* iLine; // not owned
+	};
+
+class TMLCompDataAttributeInfo;
+
+/**
+*  TMLCompDataLine 
+*  A layout line
+*/
+class TMLCompDataLine : public map<string, TMLCompDataValues>
+	{
+public:
+	enum TComponentType 
+		{ 
+		EUnknownComponent, 
+		EScreenComponent, 
+		EContainerComponent, 
+		EPaneComponent, 
+		EGraphicComponent, 
+		ETextComponent 
+		};
+
+public: // constructors etc
+	TMLCompDataLine();
+	TMLCompDataLine(const TMLCompDataLine& aOther);
+	virtual ~TMLCompDataLine();
+
+	bool operator==(const TMLCompDataLine& aOther) const;
+	static bool lessthan(TMLCompDataLine* aLeft, TMLCompDataLine* aRight);
+	bool ValuesEqual(const TMLCompDataLine& aOther) const;
+
+public: // new methods
+	bool Merge(TMLCompDataLine& aOther);
+	void Compile();
+	TMLAttributeZoomLevels* GetAttributeZoomLevels(string aAttribName, int aVariety);
+
+public: // get and set methods
+	string Name() const;					
+	bool NeedsParams() const;
+	bool NeedsOptions() const;
+	bool NeedsCols() const;
+	bool NeedsRows() const;
+	int MaxVariety() const;
+	int NumCols() const;
+	int NumRows() const;
+	void SetMaxVariety(int aMaxVariety);
+	void SetNumCols(int aNumCols);
+	void SetNumRows(int aNumRows);
+	void SetNeedsCols(bool aNeeds);
+	void SetNeedsRows(bool aNeeds);
+
+public: // helpers
+	int EncodeFontId(int aHeight, int aOutline, int aPosture, int aWeight, int aCategory) const;
+	bool MatchParams(const TMLCompDataLine& aLine) const;
+	bool MatchNameDiscountingSuffix(const TMLCompDataLine& aLine) const;
+	bool MatchType(const TMLCompDataLine& aLine) const;
+	string NameDiscountingSuffix() const;
+	string NameSuffix() const;
+
+private: // helpers
+	TMLAttributeZoomLevels* GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety);
+	TMLAttributeZoomLevels* FindAttributeZoomLevels(string aAttribSetName, int aAttribId);
+	void CompileParamLimits(TMLCompDataValues::TCompDataCellType aParamLimitType, const string& aParamLimitCellName);
+	void CompileFontHeights();
+
+
+public: // member data
+	int iId;
+	string iName;
+	TComponentType iType;
+	int iDrawingOrder;
+	int iMaxVariety;
+	TMLCompDataTable* iParentTable;
+	TMLCompDataParentInfo* iParentInfo;// owned
+	TMLCompDataAttributeInfo* iAttributeInfo;// owned
+	bool iIsUnique;
+	int iGlobalIndex;
+	bool iIsMirroredHorizontally; // i.e. l and r are swapped
+	bool iNeedsOptions; // note that can need options although numOptions is only 1, as may be needed for subtable
+	bool iNeedsCols;
+	bool iNeedsRows;
+
+private:
+	int iNumCols; // there is always at least one column
+	int iNumRows; // there is always at least one row
+	};
+
+
+//
+// Attribute Info
+//
+
+/**
+*  TMLCompDataAttributeInfoSelector
+*
+*  Contains the attribute set name, which is used to 
+*  disambiguate the attribute data for a given component
+*/
+struct TMLCompDataAttributeInfoSelector
+	{
+public:
+	TMLCompDataAttributeInfoSelector();
+	TMLCompDataAttributeInfoSelector(string aAttributeSetName);
+public:
+	string iAttributeSetName;
+	};
+
+typedef map<int, TMLCompDataAttributeInfoSelector> TMLCompDataAttributeInfoVarieties;
+
+/**
+*  TMLCompDataAttributeInfo
+*
+*  Contains the attribute info selector for each variety
+*/
+class TMLCompDataAttributeInfo : public TMLCompDataAttributeInfoVarieties
+	{
+public: // constructors etc
+	TMLCompDataAttributeInfo();
+	TMLCompDataAttributeInfo(TMLCompDataLine* aLine);
+	virtual ~TMLCompDataAttributeInfo();
+public: // new methods
+	void Merge(const TMLCompDataAttributeInfo& aOther);
+public: // member data
+	TMLCompDataLine* iLine; // not owned
+	};
+
+
+
+/**
+*  TMLCompDataTable 
+*  A layout table
+*/
+class TMLCompDataTable : public vector<TMLCompDataLine*>
+	{
+public:
+	/*
+	 * Subtables are automatically generated for contiguous collections 
+	 * of components whose names are the same, ending in _g or _t 
+	 * followed by a number. These components represent numbered
+	 * rendered objects in the specification, and often need to be 
+	 * indexed by clients of the scalable layout API.
+	 * 
+	 */
+	class TMLCompDataSubTable : public vector<int>
+		{
+	public:
+		TMLCompDataSubTable();
+		bool NeedsParams() const;
+	public:
+		bool iNeedsOption;
+		bool iNeedsCol;
+		bool iNeedsRow;
+		string iName;
+		};
+	typedef vector<TMLCompDataSubTable*> TMLCompDataSubTables;
+
+public: // constructors etc
+	TMLCompDataTable(TMLCompData* aTables);
+	TMLCompDataTable(TMLCompData* aTables, const TMLCompDataTable& aOther);
+	virtual ~TMLCompDataTable();
+	static bool lessthan(TMLCompDataTable* aLeft, TMLCompDataTable* aRight);
+
+public: // new methods
+	TMLCompDataSubTable* FindSubTable(const string& aName);
+	TMLCompDataLine* FindLine(const string& aName);
+    void Merge(TMLCompDataTable& aOther);
+	void Compile();
+	void BuildSubTables();
+	void NormalizeSubTables();
+	void DestroySubTables();
+	void SetDefaultColumnNames();
+
+public: // accessors
+	string Name();
+	static bool IsValueColumn(string aName);
+	static bool IsNumericColumn(string aName);
+	static bool IsHorizontalColumn(string aName);
+	static bool IsVerticalColumn(string aName);
+
+public: // member data
+	int iId;
+	string iName;
+	TMLCompData* iTables;
+	TMLCompDataSubTables iSubTables;
+	vector<string> iColumnNames;
+	TMLCompDataLine* iParentLine; // not owned
+	string iParentName;
+	bool iNeedsP;
+	bool iNeedsIndex;
+	bool iAppend;
+	int iFirstLineGlobalIndex;
+	};
+
+/**
+*  TMLCompData 
+*  The core layout class - this represents a complete layout, 
+*  typically loaded from a .xml file that has been exported from the 
+* layout creation tool
+*/
+class TMLCompData : public vector<TMLCompDataTable*>
+	{
+public:
+	typedef map<int, TMLCompDataLine*> TMLComponents;
+
+public: // constructors
+	TMLCompData();
+	TMLCompData(const TMLCompData& aOther);
+	TMLCompData& operator=(const TMLCompData& aOther);
+
+public: // new methods
+	virtual ~TMLCompData();
+	TMLCompDataLine* FindComponent(const string& aName) const;
+	TMLCompDataLine* FindLine(const string& aName) const;
+	TMLCompDataTable* FindTable(int aId) const;
+	TMLCompDataTable* FindTable(const string& aName) const;
+	TMLCompDataTable::TMLCompDataSubTable* FindSubTable(const string& aName) const;
+	void Merge(TMLCompData& aOther);
+	void MergeComponents(TMLCompData& aOther);
+	void Compile();
+	void CreateTables();
+	void DeleteComponents();
+
+public: // member data
+	string iName;
+	bool iCanBeMirror;
+	string iMasterName;
+	string iLayoutName;
+	string iVariantName;
+	string iResolutionHeight;
+	string iResolutionWidth;
+	string iTimestamp;
+	TMLComponents iComponents; // this is used to accumulate the lines, which are then compiled into tables
+	bool iIsBaseInstance;
+	TMLAttributes* iAttributes; // owned
+	};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompData2Cdl.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MLCOMPDATA2CDL_H
+#define MLCOMPDATA2CDL_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "MLCompData.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  MLCompDataToCdl
+*  Generate a CDL interface for a layout
+*/
+class MLCompDataToCdl
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	static void LayoutToInterface(CCdlTkInterface& aInterface, const TMLCompData& aLayout, bool aDeletesAllowed, bool aAllParams);
+	static void AddGenericApiToInterface(CCdlTkInterface& aInterface, const string& aReturnType, const string& aName, bool aNeedsOptions, bool aNeedsColsRows);
+	static void AddTableToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, bool aAllParams);
+	static void AddTableCommentToApi(TMLCompDataTable& aTable, CCdlTkApi& aApi);
+	static void AddTableCommentToApi(TMLCompDataLine& aLine, CCdlTkApi& aApi);
+	static void AddLineToInterface(CCdlTkInterface& aInterface, TMLCompDataLine& aLine, bool aAllParams);
+	static void AddParamLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataLine& aLine, bool aAllParams);
+	static void AddSubTableToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, bool aAllParams);
+	static void AddSubTableLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable);
+	static void AddSubTableParamLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, bool aAllParams);
+	static void AddParamsToFunc(TMLCompDataLine& aLine, CCdlTkFunctionApi& aFunc, bool aAllParams, bool aIsNew, bool aRowsCols);
+	static void AddParamsToFunc(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CCdlTkFunctionApi& aFunc, bool aAllParams, bool aIsNew, bool aRowsCols);
+	static void AddParamToParams(CCdlTkApiParams& aOldParams, CCdlTkApiParams& aParams, string aType, bool aAllParams, bool aIsNewLine, bool aNeedsParam);
+	static void SetHeaders(CCdlTkInterface& aInterface, const string& aCdlName, const string& aComment, int aUid, bool aRomOnly);
+	static string InterfaceName(const string& aFileName);
+	static string SubTableApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable);
+	static string SubTableLimitsApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable);
+	static string SubTableParamLimtsApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable);
+	static string LineApiName(TMLCompDataLine& aLine);
+	static string LineParamLimitsApiName(TMLCompDataLine& aLine);
+private:
+	static string MLCompDataToCdl::ReturnType(TMLCompDataLine& aLine);
+	static void ReplaceRemovedAPIs(CCdlTkInterface& aInterface, const TMLCompData& aLayout, bool aDeletesAllowed);
+	static void CleanUpAPIComments(CCdlTkInterface& aInterface);
+	static CCdlTkFunctionApi* ProcessFunctionApi(CCdlTkInterface& aInterface, string aReturnType, string aName, bool& aIsNew);
+	static CCdlTkFunctionApi* CreateFunctionApi(CCdlTkInterface& aInterface, string aReturnType, string aName);
+	static void UpdateFunctionApi(CCdlTkFunctionApi& aApi, CCdlTkInterface& aInterface, string aReturnType, string aName);
+	static void UpdateParams(CCdlTkApiParams& aOldParams, CCdlTkApiParams& aParams, string aApiName, bool aAllParamsRequested, bool aColsRowsRequired, bool aIsNew, bool aNeedsComponentId, bool aNeedsOptions, bool aNeedsCols, bool aNeedsRows);
+private:
+	typedef set<string> CApiNamesUsed;
+	static CApiNamesUsed iInterfaceNamesUsed;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompData2LayPerf.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+#ifndef MLCompData2LayPerf_H
+#define MLCompData2LayPerf_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "MLCompData.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  MLCompDataToLayPerf
+*  Compiler mode for rescaling a layout
+*/
+class MLCompDataToLayPerf
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+private:
+	MLCompDataToLayPerf(const string& aCdlName, CCdlTkInterface& aInterface, TMLCompData& aSourceLayout, const string& aDestLayoutName);
+	void WriteLayout();
+
+private:
+	TMLCompData& iLayout;
+	string iDestLayoutName;
+	string iCdlName;
+	CCdlTkInterface& iInterface; // not owned
+	};
+
+
+#endif // MLCompData2LayPerf_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompDataLayPerfWriter.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+#ifndef MLCompDataLayPerfWriter_H
+#define MLCompDataLayPerfWriter_H
+
+// disable "decorated name length exceeded, name was truncated"
+#pragma warning (disable:4503)
+
+#include "WriterBase.h"
+#include "MLCompData.h"
+
+class TMLCompDataLayPerfWriter;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  TLayPerfTableWriter
+*  Writes a layout table in .lay format
+*/
+class TMLCompDataLayPerfTableWriter
+	{
+public:
+	TMLCompDataLayPerfTableWriter(TMLCompDataLayPerfWriter* aParent, TMLCompDataTable& aTable, string& aInterfaceName, int aTableId);
+	~TMLCompDataLayPerfTableWriter();
+	void Write(ostream& out);
+
+private:
+	void WriteTable(ostream& out);
+	void WriteLine(ostream& out, TMLCompDataLine& line);
+	string BuildMacroName(TMLCompDataLine& aLine);
+	string BuildApiName(TMLCompDataLine& aLine);
+	string BuildParams(TMLCompDataLine& aLine);
+	string BuildParamLimitParams(TMLCompDataLine& aLine);
+
+private:
+	TMLCompDataLayPerfWriter* iParent;
+	TMLCompDataTable& iTable;
+	string iInterfaceName;
+	int iTableId;
+	};
+
+/**
+*  TMLCompDataLayPerfWriter 
+*  Writes a layout in LayPerf format, using the build in macros to do the work.
+*/
+class TMLCompDataLayPerfWriter : public TMLWriterBase<TMLCompData>
+	{
+public:
+	TMLCompDataLayPerfWriter(CCdlTkInterface& aInterface, TMLCompData& aLayout, const std::string& aName);
+	void Write(const std::string& aLayName);
+public:
+	CCdlTkInterface& iInterface; // not owned
+	};
+
+#endif // MLCompDataLayPerfWriter_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLCompDataParse.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#ifndef MLCOMPDATAPARSE_H
+#define MLCOMPDATAPARSE_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayoutCompilerErr.h"
+#include "MLCompData.h"
+
+#include <avkon.hrh> // for logical font ids
+
+#include "SaxErrorHandler.h"
+
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <stack>
+
+using namespace std;
+
+
+//
+// defines
+//
+#define ELayoutCompilerFontCategoryUndefined KAknFontCategoryUndefined /* 0 */
+#define ELayoutCompilerFontCategoryPrimary KAknFontCategoryPrimary /* 1*/
+#define ELayoutCompilerFontCategorySecondary KAknFontCategorySecondary /* 2 */
+#define ELayoutCompilerFontCategoryTitle KAknFontCategoryTitle /* 3 */
+#define ELayoutCompilerFontCategoryPrimarySmall KAknFontCategoryPrimarySmall /* 4 */
+#define ELayoutCompilerFontCategoryDigital KAknFontCategoryDigital /* 5 */
+
+
+class MSaxLayoutHandler
+	{
+public:
+	typedef SAX::basic_Attributes<std::string> TAttribs;
+	virtual MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs) { return this; };
+	virtual void HandleSaxEnd(const std::string& aElement) { };
+	};
+
+
+// this corresponds to a "param" in the xml
+class TMLCompDataParseValues : public TMLCompDataValues, public MSaxLayoutHandler
+	{
+public:
+	TMLCompDataParseValues(TMLCompDataLine* aLine);
+	static int ConvertZoomStr(const std::string& aValueStr);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxCalc(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void ConvertValueStr(std::string& aValueStr);
+private:
+	TMLCompDataZoomLevels* iSaxZoomLevels;
+	int iSaxVariety;
+	};
+
+// this corresponds to the contents of "ParentInfo" in the xml
+class TMLCompDataParseParentInfo : public TMLCompDataParentInfo, public MSaxLayoutHandler
+	{
+public:
+	TMLCompDataParseParentInfo(TMLCompDataLine* aLine);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	TMLCompDataParentInfoSelector* iSaxParentInfoSelector;
+	int iSaxVariety;
+	};
+
+
+class TMLCompDataParseAttributeInfo;
+
+// this corresponds to a "component" in the xml
+class TMLCompDataParseLayoutLine : public TMLCompDataLine, public MSaxLayoutHandler
+	{
+public:
+	TMLCompDataParseLayoutLine();
+	string ShortParamName(string& aName);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxAttributes(const TAttribs& aAttribs);
+	MSaxLayoutHandler* HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
+	MSaxLayoutHandler* HandleSaxParam(const std::string& aElement, const TAttribs& aAttribs);
+	MSaxLayoutHandler* HandleSaxAttributeInfo(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	TMLCompDataParseValues* iSaxValues;
+	TMLCompDataParseParentInfo* iSaxParentInfo;
+	TMLCompDataParseAttributeInfo* iSaxAttributeInfo;
+	};
+
+// this corresponds to the contents of "AttributeInfo" in the xml
+class TMLCompDataParseAttributeInfo : public TMLCompDataAttributeInfo, public MSaxLayoutHandler
+	{
+public:
+	TMLCompDataParseAttributeInfo(TMLCompDataLine* aLine);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxAttributeSet(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	TMLCompDataAttributeInfoSelector* iSaxAttributeInfoSelector;
+	int iSaxVariety;
+	};
+
+
+
+// this corresponds to a common parent component, and therefore does
+// not correspond directly to a structure in the xml, although in general
+// there is one per non-leaf component
+class TMLCompDataParseLayoutTable : public TMLCompDataTable, public MSaxLayoutHandler
+	{
+public:
+	TMLCompDataParseLayoutTable(TMLCompData* aTables);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	};
+
+// this corresponds to a layout in the xml
+class TMLCompDataParseLayout : public TMLCompData, public MSaxLayoutHandler
+	{
+public:
+	static auto_ptr<TMLCompDataParseLayout> Parse(const string& aLayName);
+public: // from MSaxLayoutHandler
+	MSaxLayoutHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	};
+
+
+class TLayoutSaxParser : private SAX::basic_DefaultHandler<std::string>
+	{
+private:
+	typedef stack<MSaxLayoutHandler*> TSaxHandlerStack;
+	typedef SAX::basic_ErrorHandler<std::string>::SAXParseExceptionT TException;
+
+public:
+	TLayoutSaxParser(MSaxLayoutHandler* aHandler);
+	void Parse(const std::string& aFileName);
+
+private: // from basic_DefaultHandler
+	void startElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName, const SAX::basic_Attributes<std::string>& atts);
+	void endElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName);
+
+	void warning(const TException& aException);
+	void error(const TException& aException);
+	void fatalError(const TException& aException);
+
+private:
+	TSaxHandlerStack iStack;	// stack content not owned
+	};
+
+
+#endif // MLCOMPDATAPARSE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLEqCompData.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,426 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+#ifndef MLEQCOMPDATA_H
+#define MLEQCOMPDATA_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated"
+#pragma warning (disable:4503)
+
+#include "MLAttributes.h"
+
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <map>
+
+using namespace std;
+
+class TMLEqCompDataLine;
+class TMLEqCompDataTable;
+class TMLEqCompData;
+class TMLAttributes;
+class FormulaTreeNode;
+
+extern const string KEqCompDataPaneOutputOrder[];
+extern const int KEqCompDataPaneOutputOrderSize;
+
+extern const string KEqCompDataKeywordParamLeft;
+extern const string KEqCompDataKeywordParamTop;
+extern const string KEqCompDataKeywordParamRight;
+extern const string KEqCompDataKeywordParamBottom;
+extern const string KEqCompDataKeywordParamWidth;
+extern const string KEqCompDataKeywordParamHeight;
+
+
+/**
+*  TMLEqCompDataFormula
+*
+* This represents a formula entry. It contains both the original string representation and any 
+* subsequent parsed and resolved versions.
+*/
+struct TMLEqCompDataFormula
+	{
+public:
+	TMLEqCompDataFormula();
+	TMLEqCompDataFormula(const TMLEqCompDataFormula& aOther);
+	TMLEqCompDataFormula(string aFormulaString);
+	const TMLEqCompDataFormula& operator=(const TMLEqCompDataFormula& aOther);
+	bool operator==(const TMLEqCompDataFormula& aOther) const;
+	virtual ~TMLEqCompDataFormula();
+public: // new methods
+	void Compile();
+public:
+	string iFormulaString; // owned, must be present for lifetime of iFormulaTree
+	int iZoomId;
+
+	// don't think that we need these as they don't seem to be used
+//	string lowerMargin;
+//	string upperMargin;
+//	string minLimit;
+//	string maxLimit;
+
+public:
+	FormulaTreeNode* iFormulaTree; // owned, but it references iFormulaString
+	};
+
+typedef vector<TMLEqCompDataFormula> TMLEqCompDataFormulae;
+
+enum TMLEqCompDataOptionSetOrientation
+	{
+	EMLEqCompDataOptionSetOrientationUndefined = 0x00,
+	EMLEqCompDataOptionSetOrientationPortrait = 0x01,
+	EMLEqCompDataOptionSetOrientationLandscape = 0x02
+	};
+
+/**
+ * TMLEqCompDataValuesOptionSet
+ * an option set for a given value, which may apply to either or both orientation
+ */
+struct TMLEqCompDataValuesOptionSet : public TMLEqCompDataFormulae
+	{
+public:
+	void Compile();
+public:
+	TMLEqCompDataOptionSetOrientation iOrientation;
+	};
+
+typedef map<int, TMLEqCompDataValuesOptionSet> TMLEqCompDataValuesOptionSets;
+
+/**
+*  TMLEqCompDataValues 
+*  The values stored in a cell in a layout line
+*/
+class TMLEqCompDataValues : public TMLEqCompDataFormulae
+	{
+public: // constructors, operators, etc
+	TMLEqCompDataValues();
+	TMLEqCompDataValues(TMLEqCompDataLine* aLine);
+	virtual ~TMLEqCompDataValues();
+	bool operator==(const TMLEqCompDataValues& aOther) const;
+
+public: // new methods
+    bool Merge(TMLEqCompDataLine* aLine, string aName, TMLEqCompDataValues& aOtherValues, bool aMirrorMerge);
+	void Compile(int aOptionSetId);
+	static string CppValue(const string& aValue);
+	static string MirrorJustificationValue(const string& aValue);
+
+public: // member data
+	TMLEqCompDataLine* iLine; // not owned
+	TMLEqCompDataValuesOptionSets iOptionSets; // owned
+	string iName;
+	};
+
+
+//
+// Parent Info
+//
+
+/**
+*  TMLEqCompDataParentInfoSelector
+*
+*  The parent id and parent variety index for each variety index
+*/
+struct TMLEqCompDataParentInfoSelector
+	{
+public:
+	TMLEqCompDataParentInfoSelector();
+	TMLEqCompDataParentInfoSelector(int aParentId, int aParentVariety);
+public:
+	int iParentId;
+	int iParentVariety;
+	};
+
+typedef map<int, TMLEqCompDataParentInfoSelector> TMLEqCompDataParentInfoVarieties;
+
+/**
+*  TMLEqCompDataParentInfo
+*
+*  Contains the parent info selector for each variety index
+*/
+class TMLEqCompDataParentInfo : public TMLEqCompDataParentInfoVarieties
+	{
+public: // constructors etc
+	TMLEqCompDataParentInfo();
+	TMLEqCompDataParentInfo(TMLEqCompDataLine* aLine);
+	virtual ~TMLEqCompDataParentInfo();
+public: // new methods
+	void Merge(const TMLEqCompDataParentInfo& aOther);
+public: // member data
+	TMLEqCompDataLine* iLine; // not owned
+	};
+
+class TMLEqCompDataAttributeInfo;
+
+/**
+*  TMLEqCompDataLine 
+*  A layout line
+*/
+class TMLEqCompDataLine : public map<string, TMLEqCompDataValues>
+	{
+public:
+	enum TComponentType 
+		{ 
+		EUnknownComponent, 
+		EScreenComponent, 
+		EContainerComponent, 
+		EPaneComponent, 
+		EGraphicComponent, 
+		ETextComponent 
+		};
+
+public: // constructors etc
+	TMLEqCompDataLine();
+	TMLEqCompDataLine(const TMLEqCompDataLine& aOther);
+	virtual ~TMLEqCompDataLine();
+
+	bool operator==(const TMLEqCompDataLine& aOther) const;
+	static bool lessthan(TMLEqCompDataLine* aLeft, TMLEqCompDataLine* aRight);
+	bool ValuesEqual(const TMLEqCompDataLine& aOther) const;
+
+public: // new methods
+	bool Merge(TMLEqCompDataLine& aOther);
+	void Compile(int aOptionSetId);
+	TMLAttributeZoomLevels* GetAttributeZoomLevels(string aAttribName, int aVariety);
+
+public: // get and set methods
+	string Name() const;					
+	int NumCols() const;
+	int NumRows() const;
+	void SetNumCols(int aNumCols);
+	void SetNumRows(int aNumRows);
+
+public: // helpers
+	int EncodeFontId(int aHeight, int aPosture, int aWeight, int aCategory) const;
+	bool MatchParams(const TMLEqCompDataLine& aLine) const;
+	bool MatchNameDiscountingSuffix(const TMLEqCompDataLine& aLine) const;
+	bool MatchType(const TMLEqCompDataLine& aLine) const;
+	string NameDiscountingSuffix() const;
+	string NameSuffix() const;
+
+private: // helpers
+	TMLAttributeZoomLevels* GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety);
+	TMLAttributeZoomLevels* FindAttributeZoomLevels(string aAttribSetName, int aAttribId);
+
+public: // member data
+	int iId;
+	string iName;
+	TComponentType iType;
+	int iDrawingOrder;
+	TMLEqCompDataTable* iParentTable;
+	TMLEqCompDataParentInfo* iParentInfo;// owned
+//	TMLEqCompDataAttributeInfo* iAttributeInfo;// owned
+	bool iIsUnique;
+	int iGlobalIndex;
+	bool iIsMirroredHorizontally; // i.e. l and r are swapped
+
+private:
+	int iNumCols; // there is always at least one column
+	int iNumRows; // there is always at least one row
+	};
+
+
+//
+// Attribute Info
+//
+
+/**
+*  TMLEqCompDataAttributeInfoSelector
+*
+*  Contains the attribute set name, which is used to 
+*  disambiguate the attribute data for a given component
+*/
+struct TMLEqCompDataAttributeInfoSelector
+	{
+public:
+	TMLEqCompDataAttributeInfoSelector();
+	TMLEqCompDataAttributeInfoSelector(string aAttributeSetName);
+public:
+	string iAttributeSetName;
+	};
+
+typedef map<int, TMLEqCompDataAttributeInfoSelector> TMLEqCompDataAttributeInfoVarieties;
+
+/**
+*  TMLEqCompDataAttributeInfo
+*
+*  Contains the attribute info selector for each variety
+*/
+class TMLEqCompDataAttributeInfo : public TMLEqCompDataAttributeInfoVarieties
+	{
+public: // constructors etc
+	TMLEqCompDataAttributeInfo();
+	TMLEqCompDataAttributeInfo(TMLEqCompDataLine* aLine);
+	virtual ~TMLEqCompDataAttributeInfo();
+public: // new methods
+	void Merge(const TMLEqCompDataAttributeInfo& aOther);
+public: // member data
+	TMLEqCompDataLine* iLine; // not owned
+	};
+
+
+typedef vector<TMLEqCompDataLine*> TMLEqCompDataLines;
+
+/**
+ * TMLEqCompDataTableOptionSet 
+ * an option set for a given value, which may apply to either or both orientation
+ */
+struct TMLEqCompDataTableOptionSet : public TMLEqCompDataLines
+	{
+public:
+	TMLEqCompDataTableOptionSet();
+	TMLEqCompDataTableOptionSet(const TMLEqCompDataTableOptionSet& aOther);
+	virtual ~TMLEqCompDataTableOptionSet();
+	void Compile(int aOptionSetId);
+public:
+	TMLEqCompDataLine* FindLine(int aId) const;
+public:
+	TMLEqCompDataOptionSetOrientation iOrientation;
+	};
+
+typedef map<int, TMLEqCompDataTableOptionSet> TMLEqCompDataTableOptionSets;
+
+/**
+*  TMLEqCompDataTable 
+*  A layout table
+*/
+class TMLEqCompDataTable : public TMLEqCompDataTableOptionSets
+	{
+public: // constructors etc
+	TMLEqCompDataTable(TMLEqCompData* aTables);
+	TMLEqCompDataTable(TMLEqCompData* aTables, const TMLEqCompDataTable& aOther);
+	virtual ~TMLEqCompDataTable();
+
+public: // new methods
+	TMLEqCompDataLine* FindLine(const string& aName);
+    void Merge(TMLEqCompDataTable& aOther);
+	void Compile();
+	void SetDefaultColumnNames();
+
+public: // accessors
+	string Name();
+	static bool IsValueColumn(string aName);
+	static bool IsNumericColumn(string aName);
+	static bool IsHorizontalColumn(string aName);
+	static bool IsVerticalColumn(string aName);
+
+public: // member data
+	int iId;
+	string iName;
+	TMLEqCompData* iTables;
+	vector<string> iColumnNames;
+	TMLEqCompDataLine* iParentLine; // not owned
+	string iParentName;
+	};
+
+
+
+
+//
+// the "List" xml is needed to get the name of each component.
+//
+
+/**
+*  TMLEqListComponent
+*
+* This is the component element stored in the list xml. 
+*/
+struct TMLEqListComponent
+	{
+public:
+	TMLEqListComponent();
+public:
+		int iId;
+		string iName;
+	};
+
+//
+// the "ParChild" xml is needed to get the parent relations
+//
+
+/**
+*  TMLEqParChildComponent
+*
+* This is the component element stored in the parent chlid xml. 
+*/
+struct TMLEqParChildComponent
+	{
+public:
+	TMLEqParChildComponent();
+public:
+	int iId;
+	int iParentId;
+	};
+
+
+
+/**
+ * TMLEqCompData 
+ *
+ * The core layout class - this represents a complete master layout, 
+ * typically loaded from a .xml file that has been extracted from the internal
+ * xml data of the layout tool
+ */
+class TMLEqCompData : public vector<TMLEqCompDataTable*>
+	{
+public:
+	typedef map<int, TMLEqListComponent*> TMLEqListComponents;
+	typedef map<int, TMLEqCompDataLine*> TMLEqCompDataComponents;
+	typedef map<int, TMLEqParChildComponent*> TMLEqParChildComponents;
+
+public: // constructors
+	TMLEqCompData();
+	TMLEqCompData(const TMLEqCompData& aOther);
+	TMLEqCompData& operator=(const TMLEqCompData& aOther);
+
+public: // new methods
+	virtual ~TMLEqCompData();
+	TMLEqCompDataLine* FindComponent(const string& aName) const;
+	TMLEqCompDataLine* FindLine(const string& aName) const;
+	TMLEqCompDataTable* FindTable(int aId) const;
+	TMLEqCompDataTable* FindTable(const string& aName) const;
+	void Merge(TMLEqCompData& aOther);
+	void MergeComponents(TMLEqCompData& aOther);
+	void Compile();
+	void UpdateNames();
+	void CreateTables();
+	void DeleteComponents();
+
+public: // member data
+	string iName;
+	bool iCanBeMirror;
+	string iMasterName;
+	string iLayoutName;
+	string iVariantName;
+	string iResolutionHeight;
+	string iResolutionWidth;
+	string iTimestamp;
+	TMLEqListComponents iListComponents; // this is used to accumulate the lines from the , which are then compiled into tables
+	TMLEqCompDataComponents iComponents; // this is used to accumulate the lines, which are then compiled into tables
+	TMLEqParChildComponents iParChildComponents; // this is used to accumulate the lines, which are then compiled into tables
+	bool iIsBaseInstance;
+	TMLAttributes* iAttributes; // owned
+	};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLEqCompData2DHuiML.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+#ifndef MLEQCOMPDATA2DHUIML_H
+#define MLEQCOMPDATA2DHUIML_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "MLEqCompData.h"
+using namespace std;
+
+
+class TEqLayoutSaxWriter;
+
+/**
+*  MLEqCompDataToDHuiML
+*  Generate a CDL interface for a layout
+*/
+class MLEqCompDataToDHuiML
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	static void LayoutTablesToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompData& aLayout);
+	static void LayoutComponentsToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompData& aLayout);
+
+	static void AddTableToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataTable& aTable);
+	static void AddLineToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataLine& aLine, int aOptionSetId);
+	static void AddCellToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataValues& aValues, const string& aCellName, int aOptionSetId);
+	static void AddFormulaToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompDataFormula& aFormula);
+
+private:
+	static void ConvertPositionValueStr(std::string& aValueStr);
+	};
+
+
+#endif // MLEQCOMPDATA2DHUIML_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MLEqCompDataParse.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,197 @@
+/*
+* 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 "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: 
+*    
+*
+*/
+
+
+#ifndef MLEQCOMPDATAPARSE_H
+#define MLEQCOMPDATAPARSE_H
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayoutCompilerErr.h"
+#include "MLEqCompData.h"
+
+#include <avkon.hrh> // for logical font ids
+
+#include "SaxErrorHandler.h"
+
+#include <vector>
+#include <string>
+#include <iosfwd>
+#include <stack>
+
+using namespace std;
+
+
+//
+// defines
+//
+#define ELayoutCompilerFontCategoryUndefined KAknFontCategoryUndefined /* 0 */
+#define ELayoutCompilerFontCategoryPrimary KAknFontCategoryPrimary /* 1*/
+#define ELayoutCompilerFontCategorySecondary KAknFontCategorySecondary /* 2 */
+#define ELayoutCompilerFontCategoryTitle KAknFontCategoryTitle /* 3 */
+#define ELayoutCompilerFontCategoryPrimarySmall KAknFontCategoryPrimarySmall /* 4 */
+#define ELayoutCompilerFontCategoryDigital KAknFontCategoryDigital /* 5 */
+
+
+class MSaxLayoutEqHandler
+	{
+public:
+	typedef SAX::basic_Attributes<std::string> TAttribs;
+	virtual MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs) { return this; };
+	virtual void HandleSaxEnd(const std::string& aElement) { };
+	};
+
+
+
+class TMLEqCompDataParseFormula : public TMLEqCompDataFormula, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqCompDataParseFormula();
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+public:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxFormulaAttributes(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	string iSaxFormulaString;
+	};
+
+
+class TMLEqCompDataParseValuesOptionSet : public TMLEqCompDataValuesOptionSet, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqCompDataParseValuesOptionSet();
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+public:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxOptionSetNo(const std::string& aElement, const TAttribs& aAttribs);
+	MSaxLayoutEqHandler* HandleSaxFormula(const std::string& aElement, const TAttribs& aAttribs);
+public:
+	int OptionSetNo() const {return iSaxOptionSetNo;}
+private:
+	TMLEqCompDataParseFormula* iSaxFormula;
+	int iSaxFormulaNo;
+	int iSaxOptionSetNo;
+	};
+
+// this corresponds to a "param" in the xml
+class TMLEqCompDataParseValues : public TMLEqCompDataValues, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqCompDataParseValues(TMLEqCompDataLine* aLine);
+	static int ConvertZoomStr(const std::string& aValueStr);
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	MSaxLayoutEqHandler* HandleSaxOptionSet(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void ConvertValueStr(std::string& aValueStr);
+private:
+	TMLEqCompDataParseValuesOptionSet* iSaxOptionSet;
+	};
+
+
+// this corresponds to a "component" in the xml
+class TMLEqCompDataParseLine : public TMLEqCompDataLine, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqCompDataParseLine();
+	string ShortParamName(string& aName);
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	void HandleSaxEnd(const std::string& aElement);
+	void HandleSaxAttributes(const TAttribs& aAttribs);
+//	MSaxLayoutEqHandler* HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
+	MSaxLayoutEqHandler* HandleSaxParam(const std::string& aElement, const TAttribs& aAttribs);
+//	MSaxLayoutEqHandler* HandleSaxAttributeInfo(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	TMLEqCompDataParseValues* iSaxValues;
+//	TMLEqCompDataParseParentInfo* iSaxParentInfo;
+//	TMLEqCompDataParseAttributeInfo* iSaxAttributeInfo;
+	};
+
+
+// This is the component element stored in the list xml. 
+class TMLEqListParseComponent : public TMLEqListComponent, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqListParseComponent();
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxEnd(const std::string& aElement);
+	};
+
+
+// This is the component element stored in the list xml. 
+class TMLEqParChildParseComponent : public TMLEqParChildComponent, public MSaxLayoutEqHandler
+	{
+public:
+	TMLEqParChildParseComponent();
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxEnd(const std::string& aElement);
+private:
+	void HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs);
+	};
+
+// this corresponds to a layout in the xml
+class TMLEqCompDataParseLayout : public TMLEqCompData, public MSaxLayoutEqHandler
+	{
+public:
+	static auto_ptr<TMLEqCompDataParseLayout> Parse(const string& aListName, const string& aCompDataName, const string& aParChildName);
+public: // from MSaxLayoutEqHandler
+	MSaxLayoutEqHandler* HandleSax(const std::string& aElement, const TAttribs& aAttribs);
+	void HandleSaxEnd(const std::string& aElement);
+private:
+	MSaxLayoutEqHandler* HandleSaxComponent(const std::string& aElement, const TAttribs& aAttribs);
+private:
+	TMLEqCompDataParseLine* iSaxLine;
+	string iSaxLayoutType;
+	};
+
+
+class TEqLayoutSaxParser : private SAX::basic_DefaultHandler<std::string>
+	{
+private:
+	typedef stack<MSaxLayoutEqHandler*> TSaxHandlerStack;
+	typedef SAX::basic_ErrorHandler<std::string>::SAXParseExceptionT TException;
+
+public:
+	TEqLayoutSaxParser(MSaxLayoutEqHandler* aHandler);
+	void Parse(const std::string& aFileName);
+
+private: // from basic_DefaultHandler
+	void startElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName, const SAX::basic_Attributes<std::string>& atts);
+	void endElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName);
+
+	void warning(const TException& aException);
+	void error(const TException& aException);
+	void fatalError(const TException& aException);
+
+private:
+	TSaxHandlerStack iStack;	// stack content not owned
+	};
+
+
+#endif // MLEQCOMPDATAPARSE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MakeLayConvTest.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MAKELAYCONVTEST_H
+#define MAKELAYCONVTEST_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+
+/**
+*  MakeLayoutConvTest
+*  Generate test code to test the validity of the conversion from the older 
+*  AknLayout system to AknLayout2
+*/
+class MakeLayoutConvTest
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	MakeLayoutConvTest(CCdlTkInterface& aInterface, TLayout& aLayout);
+	~MakeLayoutConvTest();
+	void RunProcess();
+
+private:
+	void AddTableToTest(TLayoutTable& aTable);
+	void WriteTestFiles();
+	void WriteTestFile(const string& aFileName, const string& iContent);
+	void InitFiles();
+	void CompleteFiles();
+	void AddLineToTest(TLayoutLine& aLine);
+	void AddTest(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi);
+	const CCdlTkFunctionApi* FindApi(const string& aName);
+
+	void AddTestToOldH(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi);
+	void AddTestToOldCpp(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi);
+	void AddTestFunc(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi);
+
+	string OldFuncSig(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi);
+
+private:
+	CCdlTkInterface& iInterface;
+	TLayout& iLayout;
+	string iOldH;
+	string iOldCpp;
+	string iFuncs;
+	string iTests;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/MasterLayoutPack.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef MASTERLAYOUTPACK_H
+#define MASTERLAYOUTPACK_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkinstance.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+/**
+*  MasterLayoutPackage
+*  Write a master layout package according to the MasterLayoutPack.cdl interface
+*/
+class MasterLayoutPackage
+	{
+public:
+	static int Process(vector<string>& args);
+	static void ShowHelp(ostream& stream);
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/SaxErrorHandler.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       Defines the entry point for the console application
+*
+*/
+
+
+
+//
+// class SAXErrorHandler
+//
+
+#ifndef __SAXERRORHANDLER_H_
+#define __SAXERRORHANDLER_H_
+
+#include <DOM/SAX2DOM/SAX2DOM.h>
+
+class SAXErrorHandler : public SAX::ErrorHandler
+	{
+public:
+  SAXErrorHandler() { }
+  virtual ~SAXErrorHandler() { }
+public: // from SAX::ErrorHandler
+  virtual void warning(const SAX::SAXParseException&);
+  virtual void error(const SAX::SAXParseException&);
+  virtual void fatalError(const SAX::SAXParseException& exception);
+	};
+
+#endif // __SAXERRORHANDLER_H_
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/Script.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef SCRIPT_H
+#define SCRIPT_H
+
+#include <iosfwd>
+#include <vector>
+#include <string>
+using namespace std;
+
+/**
+*  AknLayoutCompilerScript
+*  Intended to be a script interpreter for the layout compiler - not yet complete
+*/
+class AknLayoutCompilerScript
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	AknLayoutCompilerScript(istream& aIn);
+	void Process();
+
+private:
+	void ProcessLine(string& aLine);
+	void Process(const string& aFunc, const vector<string>& aParamList, const string& aResult);
+
+private:
+	istream& iIn;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/UpdateLayoutApi.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef UPDATELAYOUTAPI_H
+#define UPDATELAYOUTAPI_H
+
+#include <string>
+#include <vector>
+#include <iosfwd>
+#include "Layout.h"
+using namespace std;
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace CdlCompilerToolkit;
+
+/**
+*  UpdateLayoutApi 
+*  Intended to update a CDL interface for a layout - not yet complete
+*/
+class UpdateLayoutApi : public MCdlTkApiCheckObserver
+	{
+public:
+	static int Process(const vector<string>& args);
+	static void ShowHelp(ostream& stream);
+
+	UpdateLayoutApi(const std::string& aCdlName, const std::string& aLayoutName, const std::string& aLegacyName, const std::string& aNewName);
+	~UpdateLayoutApi();
+
+private:
+	void LoadFiles(const std::string& aLayoutName, const std::string& aNewName);
+	void MergeAndCheck();
+	void ProcessNewApi();
+	void WriteFiles();
+	void Report();
+	void AddDataToLegacy(const std::string& aOldName, const std::string& aNewName);
+
+private:
+	virtual void StartCheck();
+	virtual void CheckComplete();
+	virtual void ApiInBoth(const CCdlTkApi& aApi);
+	virtual void ApiNotInLeft(const CCdlTkApi& aApi);
+	virtual void ApiNotInRight(const CCdlTkApi& aApi);
+
+private:
+	class InterfaceCheck : public MCdlTkApiCheckObserver
+		{
+		virtual void StartCheck();
+		virtual void CheckComplete();
+		virtual void ApiInBoth(const CCdlTkApi& aApi);
+		virtual void ApiNotInLeft(const CCdlTkApi& aApi);
+		virtual void ApiNotInRight(const CCdlTkApi& aApi);
+		};
+
+private:
+	std::string iLegacyName;
+	std::string iCdlName;
+	CCdlTkInterface* iInterface;
+	TLayout* iLayout;
+	TLayout* iLegacy;
+	TLayout* iNew;
+	CCdlTkInterface* iExt;	// not owned
+	bool iInterfaceChanged;
+	bool iLegacyUpdated;
+	string iReport;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/UsefulDefinitions.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef USEFULDEFINITIONS_H
+#define USEFULDEFINITIONS_H
+
+#define ARRAY_LEN(x) (sizeof(x)/sizeof(*(x)))
+#define ARRAY_END(x) (x+(sizeof(x)/sizeof(*(x))))
+
+
+#endif // USEFULDEFINITIONS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/WriterBase.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+#ifndef WRITERBASE_H
+#define WRITERBASE_H
+
+#include "layout.h"
+
+/**
+*  TWriterBase
+*  Base class for layout writers
+*/
+class TWriterBase
+	{
+public:
+	TWriterBase(const std::string& aName);
+	virtual ~TWriterBase();
+	virtual void Write(const std::string& aLayName) = 0;
+protected:
+	string iName;
+	};
+
+class TLayWriterBase : public TWriterBase
+	{
+public:
+	TLayWriterBase(TLayout& aLayout, const std::string& aName);
+	virtual ~TLayWriterBase();
+	virtual void Write(const std::string& aLayName) = 0;
+protected:
+	TLayout& iLayout;
+	};
+
+template <class T>
+class TMLWriterBase : public TWriterBase
+	{
+public:
+	TMLWriterBase(T& aLayout, const std::string& aName) : TWriterBase(aName), iLayout(aLayout) {};
+	virtual ~TMLWriterBase() {};
+	virtual void Write(const std::string& aLayName) = 0;
+protected:
+	T& iLayout;
+	};
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/inc/ZoomLevelNames.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef ZOOMLEVELNAMES_H
+#define ZOOMLEVELNAMES_H
+
+#include <string>
+#include <vector>
+#include <map>
+using namespace std;
+
+/*
+ * CZoomLevelNames
+ */
+class CZoomLevelNames : public map<int, string>
+	{
+public:
+	// ProcessOptions will remove "-z<zoomLevelsListFile>" from aArgs
+	void ProcessOptions(vector<string>& aArgs);
+	};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/AdaptationLayerTemplate.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,256 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "AdaptationLayerTemplate.h"
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "LayoutWriter.h"
+#include "CppWriter.h"
+#include "Lay2Cdl.h"
+#include <fstream>
+#include <algorithm>
+#include <iostream>
+#include <sstream>
+#include "CodeGenConsts.h"
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<AdaptationLayerTemplate> AdaptationLayerTemplateArgsErr;
+
+
+
+
+int AdaptationLayerTemplate::Process(const vector<string>& args)
+	{
+	if (args.size() < 6)
+		throw AdaptationLayerTemplateArgsErr();
+
+	string layName = args[2];
+	auto_ptr<TLayParseLayout> layoutParse = TLayParseLayout::Parse(layName);
+
+	string layCdlName = args[3];
+	CCdlTkCdlFileParser layCdlParser(layCdlName);
+	auto_ptr<CCdlTkInterface> layIface(layCdlParser.LoadAndParse(true));
+
+	string scaleCdlName = args[4];
+	CCdlTkCdlFileParser scaleCdlParser(scaleCdlName);
+	auto_ptr<CCdlTkInterface> scaleIface(scaleCdlParser.LoadAndParse(true));
+
+	string instName = args[5];
+	auto_ptr<CCdlTkInstance> inst(new CCdlTkInstance(*layIface));
+	inst->SetName(instName);
+	inst->TemplateAllImplementations();
+
+	string existing;
+	if (args.size() == 8)
+		{
+		string inputName = args[6];
+		CdlTkUtil::ReadFile(existing, inputName);
+		}
+
+	AdaptationLayerTemplate process(*layoutParse, *layIface, *scaleIface, *inst, existing);
+	process.Process();
+
+	CCdlTkWriteInstance writer(*inst);
+	writer.Process();
+
+	if (args.size() == 8)
+		{
+		string outputName = args[7];
+		CdlTkUtil::WriteFile(existing, outputName);
+		}
+
+	return 0;
+	}
+
+void AdaptationLayerTemplate::ShowHelp(ostream& stream)
+	{
+	stream << "AdaptationLayerTemplate <layout.lay> <layInterface.cdl> <scaleInterface.cdl> <instanceName> [<existingImplToModify> <fileToWriteModsTo>]" << endl;
+	stream << "  Creates a template layout adaptation layer implementation." << endl;
+	}
+
+
+AdaptationLayerTemplate::AdaptationLayerTemplate(TLayout& aLayout, CCdlTkInterface& aLayIface, CCdlTkInterface& aScaleIface, CCdlTkInstance& aInstance, string& aExisting)
+: iLayout(aLayout), iLayIface(aLayIface), iScaleIface(aScaleIface), iInstance(aInstance), iExisting(aExisting)
+	{
+	}
+
+AdaptationLayerTemplate::~AdaptationLayerTemplate()
+	{
+	}
+
+void AdaptationLayerTemplate::Process()
+	{
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		AddTableToInstance(**pTab);
+		}
+	}
+
+void AdaptationLayerTemplate::AddTableToInstance(TLayoutTable& aTable)
+	{
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		TLayoutLine& line = **pLine;
+		AddLineToInstance(line);
+		}
+	}
+
+void AdaptationLayerTemplate::AddLineToInstance(TLayoutLine& aLine)
+	{
+	string apiName = LayoutToCdl::LineApiName(aLine);
+	if (!HasApi(apiName))
+		return;
+	CCdlTkImplementation& imp = FindImp(apiName);
+	SetFuncLine(imp, aLine);
+	}
+
+bool AdaptationLayerTemplate::HasApi(const string& aName)
+	{
+	return iLayIface.ApiList().Find(aName) != 0;
+	}
+
+CCdlTkImplementation& AdaptationLayerTemplate::FindImp(const string& aName)
+	{
+	CCdlTkImplementation* impl = iInstance.Impl().Find(aName);
+	if (!impl)
+		throw NotFoundErr(aName + " in interface " + iLayIface.FileName());
+	return *impl;
+	}
+
+int CountMatch(const string& aLeft, const string& aRight)
+	{
+	string left(CdlTkUtil::ToLower(aLeft));
+	left = CdlTkUtil::Replace("_line_", "", left);
+	string right(CdlTkUtil::ToLower(aRight));
+
+	int count = 0;
+	int subLen = 3;
+	int leftSize = left.size();
+	const int maxPossibleHits = (leftSize + 1 - subLen);
+	for (int ii=0; ii<maxPossibleHits; ii++)
+		{
+		if (right.find(left.substr(ii, subLen)) != string::npos)
+			count++;
+		}
+
+	const int KMatchPercentLimit = 25;
+	int percent = count * 100 / maxPossibleHits;
+	if (percent < KMatchPercentLimit)
+		return 0;
+	return percent;
+	}
+
+pair<string,int> AdaptationLayerTemplate::GetApiMatch(const string& aName)
+	{
+	int size = aName.size();
+	CCdlTkApiList& apiList = iScaleIface.ApiList();
+	string bestMatch;
+	int bestScore = 0;
+	for (CCdlTkApiList::iterator pApi = apiList.begin(); pApi != apiList.end(); ++pApi)
+		{
+		CCdlTkApi& api = **pApi;
+		string name = api.Name();
+		if (aName == name)
+			return make_pair(name,100);
+
+		int score = CountMatch(aName, name);
+		if (score > bestScore)
+			{
+			bestScore = score;
+			bestMatch = name;
+			}
+		}
+	return make_pair(bestMatch, bestScore);
+	}
+
+bool IsValueCell(const string& aCellName)
+	{
+	return
+		(find(KWindowOutputOrder, KWindowOutputOrder+KWindowOutputOrderSize, aCellName) != KWindowOutputOrder+KWindowOutputOrderSize)
+		||
+		(find(KTextOutputOrder, KTextOutputOrder+KTextOutputOrderSize, aCellName) != KTextOutputOrder+KTextOutputOrderSize);
+	}
+
+const string KUsefulInfo = "\
+// $LAYOUT\n\
+// Remark                    : $REMARK\n\
+// Parent                    : $PARENTNAME\n\
+// Parent API                : $PARENTAPI\n\
+// Scale API match    ($AM%) : $SCALEAPI\n\
+// Scale parent match ($PM%) : $SCALEPARENT\n\
+";
+
+void AdaptationLayerTemplate::SetFuncLine(CCdlTkImplementation& aImp, TLayoutLine& aLine)
+	{
+	string layout;
+	for (TLayoutLine::iterator pCell = aLine.begin(); pCell != aLine.end(); ++pCell)
+		{
+		const string& cellName = pCell->first;
+		if (IsValueCell(cellName))
+			{
+			TValues& values = pCell->second;
+			stringstream s;
+			TLayoutTableWriter::WriteCell(s, values);
+			CdlTkUtil::AppendString(layout, cellName);
+			CdlTkUtil::AppendString(layout, "=");
+			CdlTkUtil::AppendString(layout, s.str());
+			CdlTkUtil::AppendString(layout, " ");
+			}
+		}
+
+	string parent;
+	string parentApi;
+	if (aLine.iTable && aLine.iTable->iParent)
+		{
+		parent = aLine.iTable->iParent->Name();
+		parentApi = LayoutToCdl::LineApiName(*aLine.iTable->iParent);
+		}
+
+	pair<string,int> apiMatch(GetApiMatch(LayoutToCdl::LineApiName(aLine)));
+	pair<string,int> parentMatch(GetApiMatch(parentApi));
+
+	char apiPercent[12];
+	sprintf(apiPercent, "%3d", apiMatch.second);
+	char parentPercent[12];
+	sprintf(parentPercent, "%3d", parentMatch.second);
+
+	CdlTkUtil::CReplaceSet set;
+	set.Add("$LAYOUT", layout);
+	set.Add("$REMARK", aLine["Remarks"][0]);
+	set.Add("$PARENTNAME", parent);
+	set.Add("$PARENTAPI", parentApi);
+	set.Add("$SCALEAPI", apiMatch.first);
+	set.Add("$SCALEPARENT", parentMatch.first);
+	set.Add("$AM", apiPercent);
+	set.Add("$PM", parentPercent);
+	string useful = CdlTkUtil::MultiReplace(set, KUsefulInfo);
+
+	string defn = aImp.Definition();
+	string existingTarget = defn.substr(0,defn.find_first_of('(')+1);
+	string existingSub = useful;
+	CdlTkUtil::AppendString(existingSub, existingTarget);
+	iExisting = CdlTkUtil::Replace(existingTarget, existingSub, iExisting);
+
+	CdlTkUtil::AppendString(useful, defn);
+	aImp.SetDefinition(useful);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/AknLayoutCompiler.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       Defines the entry point for the console application
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated" warning	
+#pragma warning (disable:4503)
+
+
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "extract.h"
+#include "LayoutCompilerErr.h"
+#include "Lay2Cdl.h"
+#include "Cdl2Lag.h"
+#include "LayCdl2Inst.h"
+#include "LayCdlCheck.h"
+#include "LayoutPack.h"
+#include "LayCdl2InstO.h"
+#include "MakeLayConvTest.h"
+#include "LayScale.h"
+#include "AdaptationLayerTemplate.h"
+#include "Lay2LayPerf.h"
+
+#ifdef RD_XML_PARSER_TOOLCHAIN
+#include "MLCompData2Cdl.h"
+#include "MLCompCdl2InstO.h"
+#include "MLCompData2LayPerf.h"
+#include "MLEqCompData2DHuiML.h"
+#endif
+
+using namespace std;
+
+// In debug builds, we want the debugger to catch exceptions. In release mode we want
+// to report exceptions to the command line user.
+// The EXCEPTION_HANDLING macro flag controls this behavior in main()
+#ifndef _DEBUG
+#define EXCEPTION_HANDLING
+#endif
+
+class MainArgsErr : public LayoutCompilerErr
+	{
+	void Show(ostream& aStream) const;
+	};
+
+void MainArgsErr::Show(ostream& stream) const
+	{
+	stream << endl;
+	stream << "AknLayoutCompiler @scriptfile" << endl;
+	stream << "AknLayoutCompiler [<options>] <mode> [args]" << endl;
+	stream << "  <options> are:" << endl;
+	stream << "    -p<output path>  has no effect in this version of AknLayoutCompiler." << endl;
+	stream << "  <mode> modes are listed below" << endl;
+	stream << "  [args] depends on <mode> as listed below" << endl;
+	LayoutExtract::ShowHelp(stream);
+	LayoutToCdl::ShowHelp(stream);
+	CdlToLag::ShowHelp(stream);
+	LayoutAndCdlToCdlInstance::ShowHelp(stream);
+	LayCdlCheck::ShowHelp(stream);
+	LayoutPackage::ShowHelp(stream);
+	LayoutCdlInstanceOpt::ShowHelp(stream);
+	MakeLayoutConvTest::ShowHelp(stream);
+	LayoutScale::ShowHelp(stream);
+	AdaptationLayerTemplate::ShowHelp(stream);
+	LayoutToLayPerf::ShowHelp(stream);
+#ifdef RD_XML_PARSER_TOOLCHAIN
+	MLCompDataToCdl::ShowHelp(stream);
+	MLCompDataCdlInstanceOpt::ShowHelp(stream);
+	MLEqCompDataToDHuiML::ShowHelp(stream);
+#endif
+	}
+
+int DoMain(int argc, char* argv[])
+	{
+	CdlTkUtil::SetCommandLine(argc, argv);
+
+	vector<string> args;
+	copy(argv, argv+argc, back_inserter(args));
+
+	if (args.size() < 2)
+		{
+		throw MainArgsErr();
+		}
+
+	if (args[1].size() >= 2 && args[1].substr(0,2) == "-p")
+		{
+		CdlTkUtil::SetOutputPath(args[1].substr(2));
+		args.erase(args.begin()+1);
+		}
+
+	string& modeName = CdlTkUtil::ToLower(args[1]);
+
+	if (modeName == "extract")
+		{
+		LayoutExtract extract;
+		return extract.Extract(args);
+		}
+	else if (modeName == "lay2cdl")
+		{
+		return LayoutToCdl::Process(args);
+		}
+	else if (modeName == "cdl2lag")
+		{
+		return CdlToLag::Process(args);
+		}
+	else if (modeName == "laycdl2inst")
+		{
+		return LayoutAndCdlToCdlInstance::Process(args);
+		}
+	else if (modeName == "laycdlcheck")
+		{
+		return LayCdlCheck::Process(args);
+		}
+	else if (modeName == "laypkg")
+		{
+		return LayoutPackage::Process(args);
+		}
+	else if (modeName == "laycdl2insto")
+		{
+		return LayoutCdlInstanceOpt::Process(args);
+		}
+	else if (modeName == "makelayconvtest")
+		{
+		return MakeLayoutConvTest::Process(args);
+		}
+	else if (modeName == "layscale")
+		{
+		return LayoutScale::Process(args);
+		}
+	else if (modeName == "adaptationlayertemplate")
+		{
+		return AdaptationLayerTemplate::Process(args);
+		}
+	else if (modeName == "lay2layperf")
+		{
+		return LayoutToLayPerf::Process(args);
+		}
+#ifdef RD_XML_PARSER_TOOLCHAIN
+	else if (modeName == "mlcompdata2cdl")
+		{
+		return MLCompDataToCdl::Process(args);
+		}
+	else if (modeName == "mlcompcdl2insto")
+		{
+		return MLCompDataCdlInstanceOpt::Process(args);
+		}
+	else if (modeName == "mlcompdata2layperf")
+		{
+		return MLCompDataToLayPerf::Process(args);
+		}
+	else if (modeName == "mleqcompdata2dhuiml")
+		{
+		return MLEqCompDataToDHuiML::Process(args);
+		}
+#endif	
+	else
+		{
+		throw MainArgsErr();
+		}
+
+	return 1;
+	}
+
+int main(int argc, char* argv[])
+	{
+#ifdef EXCEPTION_HANDLING
+	try
+		{
+#endif
+		return DoMain(argc, argv);
+#ifdef EXCEPTION_HANDLING
+		}
+	catch (const CdlCompilerToolkitErr& aErr)
+		{
+		aErr.Show(cerr);
+		}
+
+	return 1;
+#endif
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Cdl2Lag.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       Defines the entry point for the console application
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "Cdl2Lag.h"
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include <fstream>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<CdlToLag> CdlToLagArgsErr;
+
+
+CdlToLag::CdlToLag(ofstream& aLag, const string& aLagName)
+: iLag(aLag), iLagName(aLagName)
+	{
+	}
+
+int CdlToLag::Process(const vector<string>& args)
+	{
+	if (args.size() < 4)
+		throw CdlToLagArgsErr();
+
+	string lagName = args[2];
+	ofstream lag;
+	CCdlTkFileCleanup temp;
+	CdlTkUtil::OpenTempOutput(lag, temp);
+
+	CdlToLag process(lag, lagName);
+	process.Start();
+
+	for (int ii = 3; ii < args.size(); ii++)
+		{
+		string cdlName = args[ii];
+		CCdlTkCdlFileParser parser(cdlName);
+		auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+		process.AddInterface(*iface);
+		}
+
+	process.Finish();
+
+	lag.close();
+	CdlTkUtil::ExportFile(temp, KDirEpocSysHeader+CdlTkUtil::StripPath(lagName));
+
+	return 0;
+	}
+
+void CdlToLag::ShowHelp(ostream& stream)
+	{
+	stream << "Cdl2Lag <lagName> <CdlNames>" << endl;
+	}
+
+void CdlToLag::Start()
+	{
+	WriteHeader();
+	}
+
+void CdlToLag::Finish()
+	{
+	WriteFooter();
+	}
+
+void CdlToLag::AddInterface(CCdlTkInterface& aInterface)
+	{
+	iInterface = &aInterface;
+	WriteInclude();
+	CCdlTkApiList& list = iInterface->ApiList();
+	for (CCdlTkApiList::iterator pApi = list.begin(); pApi != list.end(); ++pApi)
+		{
+		WriteMacro(**pApi);
+		}
+	}
+
+void CdlToLag::WriteHeader()
+	{
+	iLag << "// " << iLagName << " generated by:" << endl;
+	iLag << "// " << CdlTkUtil::CommandLine() << endl;
+	string guardName = CdlTkUtil::ToUpper(CdlTkUtil::ToCpp(CdlTkUtil::StripPath(iLagName)));
+	iLag << "#if !defined(" << guardName << ")" << endl;
+	iLag << "#define " << guardName << endl;
+	}
+
+void CdlToLag::WriteInclude()
+	{
+	iLag << "#include <" << CdlTkUtil::StripPath(iInterface->FileName()) << ".h>" << endl;
+	}
+
+void CdlToLag::WriteMacro(CCdlTkApi& aApi)
+	{
+	string macro = "#define ";
+	const string& name = aApi.Name();
+	string macroName = name;
+	if (aApi.IsFunc() && aApi.AsFunc().Params().size() && aApi.AsFunc().Params()[0].Name() == KParamLineIndex)
+		{
+		macro += "AKN_LAYOUT_TABLE_";
+		}
+	else if (aApi.ReturnType() == KTypeWindowLineLayout)
+		{
+		macro += "AKN_LAYOUT_WINDOW_";
+		}
+	else if (aApi.ReturnType() == KTypeTextLineLayout)
+		{
+		macro += "AKN_LAYOUT_TEXT_";
+		}
+	else if (aApi.ReturnType() == KTypeLayoutTableLimits)
+		{
+		macro += "AKN_LAYOUT_TABLE_LIMITS_";
+		}
+	else
+		{
+		macro += "AKN_LAYOUT_MULTILINE_TEXT_";
+		macroName = macroName.substr(KFuncMultiline.length());	// remove "Multiline_"
+		}
+
+	macro += macroName + " " + iInterface->NamespaceName() + "::" + name;
+	if (aApi.AsFunc().Params().size() == 0)	// was once data only API
+		macro += "()";
+
+	iLag << macro << endl;
+	}
+
+void CdlToLag::WriteFooter()
+	{
+	iLag << "#endif" << endl;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/CoreParser.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,517 @@
+/*
+* 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 "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:
+*
+*/
+#include "CoreParser.h"
+#include <sstream>
+#include <iostream>
+using namespace std;
+
+
+ParseResult::ParseResult()
+: iRuleId(0), iStart(0), iEnd(0)
+	{
+	}
+
+bool ParseResult::Matched() const
+	{
+	return iRuleId != 0;
+	}
+
+ParseResult ParseResult::Fail()
+	{
+	ParseResult p;
+	return p;
+	}
+
+
+Parser::Parser()
+: iOp(ENul), iMatch(0), iSub1(0), iSub2(0), iId(-1)
+	{
+	}
+
+Parser::Parser(const char* aMatch)
+: iOp(EExact), iMatch(aMatch), iSub1(0), iSub2(0), iId(-1)
+	{
+	}
+
+Parser::Parser(T0Op aOp)
+: iOp(aOp), iMatch(0), iSub1(0), iSub2(0), iId(-1)
+	{
+	}
+
+Parser::Parser(T1Op aOp, const Parser& aSub)
+: iOp(aOp), iMatch(0), iSub1(&aSub), iSub2(0), iId(-1)
+	{
+	}
+
+Parser::Parser(T2Op aOp, const Parser& aFirst, const Parser& aRest)
+: iOp(aOp), iMatch(0), iSub1(&aFirst), iSub2(&aRest), iId(-1)
+	{
+	}
+
+Parser::Parser(const Parser& aOther)
+	{
+	*this = aOther;
+	}
+
+const Parser& Parser::operator=(const Parser& aOther)
+	{
+	if (this == &aOther)
+		return *this;
+
+	iOp = aOther.iOp;
+	iMatch = aOther.iMatch;
+	iSub1 = 0;
+	iSub2 = 0;
+	iSub1 = aOther.iSub1;
+	iSub2 = aOther.iSub2;
+	iId = aOther.iId;
+//	if (aOther.iSub1)
+//		iSub1 = new Parser(*aOther.iSub1);
+//	if (aOther.iSub2)
+//		iSub2 = new Parser(*aOther.iSub2);
+
+	return *this;
+	}
+
+Parser::~Parser()
+	{
+//	delete iSub1;
+//	delete iSub2;
+	}
+
+Parser Parser::EOS()
+	{
+	return Parser(EEos);
+	}
+
+Parser Parser::Int()
+	{
+	return Parser(EInt);
+	}
+
+Parser Parser::Real()
+	{
+	return Parser(EReal);
+	}
+
+const Parser& Parser::Nul()
+	{
+	static Parser nul(ENul);
+	nul.SetId(0);
+	return nul;
+	}
+
+
+ParseResult Parser::Parse(const std::string& aString) const
+	{
+	vector<Step> stack;
+	stack.push_back(Step(this, 0, -1));
+	TMatchRes res = EContinue;
+	bool done = false;
+
+	while (!stack.empty() && !done)
+		{
+		Step& top = stack.back();
+		int topId = stack.size()-1;
+		switch (res)
+			{
+			case EFail:
+				if (top.iRule->iOp == EAlt && top.iStep < 2)
+					{
+					res = top.iRule->ParseStep(topId, aString, top.iPos, stack);
+					}
+				else if (top.iRule->iOp == EMult && top.iStep < 2)
+					{
+					top.iStep = 2;
+					res = top.iRule->ParseStep(topId, aString, top.iPos, stack);
+					}
+				else
+					{
+					if (top.iParent >= 0 && stack[top.iParent].iRule->iOp == ESeq)
+						stack[top.iParent].iStep--;
+					stack.pop_back();
+					}
+				break;
+
+			case EPass:
+				{
+				int nextSeq = -1;
+				for (int i=stack.size()-1; nextSeq==-1 && i>=0; i--)
+					{
+					if ((stack[i].iRule->iOp == ESeq && stack[i].iStep < 2) || 
+						(stack[i].iRule->iOp == EMult && stack[i].iStep < 3))
+						nextSeq = i;
+					}
+				if (nextSeq >= 0)
+					res = stack[nextSeq].iRule->ParseStep(nextSeq, aString, top.iResult.iEnd, stack);
+				else
+					done = true;
+				break;
+				}
+
+			case EContinue:
+				res = top.iRule->ParseStep(topId, aString, top.iPos, stack);
+				break;
+			}
+		}
+
+	if (done)
+		{
+		for (int i=stack.size()-1; i>=1; i--)
+			{
+			Step& step = stack[i];
+			Step& parent = stack[step.iParent];
+			parent.iResult.iChildren.push_front(step.iResult);
+			if (parent.iResult.iEnd < step.iResult.iEnd)
+				parent.iResult.iEnd = step.iResult.iEnd;
+			}
+
+		return stack[0].iResult;
+		}
+	else
+		return ParseResult::Fail();
+	}
+
+Parser::TMatchRes Parser::ParseStep(int aStepId, const std::string& aString, int aPos, vector<Step>& aStack) const
+	{
+	Step& step = aStack[aStepId];
+	step.iResult.iRuleId = Id();
+	
+	switch (iOp)
+		{
+		case EExact:
+			{
+			string match(iMatch);
+			int mLen = match.size();
+			if (mLen + aPos > aString.size())
+				return EFail;
+			else if (aString.substr(aPos, mLen) != match)
+				return EFail;
+			else
+				step.iResult.iEnd = aPos + mLen;
+			return EPass;
+			}
+
+		case EEos:
+			{
+			if (aPos != aString.size())
+				return EFail;
+			else
+				step.iResult.iEnd = aPos;
+			return EPass;
+			}
+
+		case EInt:
+			{
+			istringstream strm(aString.substr(aPos));
+			int temp;
+			strm >> temp;
+			int len = strm.tellg();
+			if (len >= 0)
+				step.iResult.iEnd = aPos + len;
+			else
+				return EFail;
+			return EPass;
+			}
+
+		case EReal:
+			{
+			istringstream strm(aString.substr(aPos));
+			double temp;
+			strm >> temp;
+			int len = strm.tellg();
+			if (len >= 0)
+				step.iResult.iEnd = aPos + len;
+			else
+				return EFail;
+			return EPass;
+			}
+
+		case ENul:
+			{
+			step.iResult.iChildren.clear();
+			step.iResult.iEnd = aPos;
+			return EPass;
+			}
+
+		case EMult:
+			{
+/*			Step next(iSub1, aPos, aStepId);
+			if (step.iStep == 1)
+				next.iRule = this;
+			else if (step.iStep == 2)
+				next.iRule = &Parser::Nul();
+			step.iStep++;
+			aStack.push_back(next);
+			return EContinue;
+*/
+			return EFail;
+			}
+
+		case ESeq:
+			{
+			Step next(iSub1, aPos, aStepId);
+			if (step.iStep == 1)
+				next.iRule = iSub2;
+			step.iStep++;
+			aStack.push_back(next);
+			return EContinue;
+			}
+
+		case EAlt:
+			{
+			Step next(iSub1, aPos, aStepId);
+			if (step.iStep == 1)
+				next.iRule = iSub2;
+			step.iStep++;
+			aStack.push_back(next);
+			return EContinue;
+			}
+		}
+
+	return EFail;
+	}
+
+int Parser::Id() const
+	{
+	return iId;
+	}
+
+void Parser::SetId(int aId)
+	{
+	iId = aId;
+	}
+
+
+Parser operator|(const Parser& aFirst, const Parser& aRest)
+	{
+	return Parser(Parser::EAlt, aFirst, aRest);
+	}
+
+Parser operator>>(const Parser& aFirst, const Parser& aRest)
+	{
+	return Parser(Parser::ESeq, aFirst, aRest);
+	}
+
+/*Parser operator*(const Parser& aSub)
+	{
+	return Parser(Parser::EMult, aSub);
+	}
+*/
+
+void DoPrint(const ParseResult& res)
+	{
+	cout << res.iRuleId << " " << res.iStart << "..." << res.iEnd << " ";
+	if (res.iChildren.size())
+		{
+		cout << "{ ";
+		for (int i=0; i<res.iChildren.size(); i++)
+			DoPrint(res.iChildren[i]);
+		cout << "} ";
+		}
+	}
+
+void Print(const ParseResult& res)
+	{
+	DoPrint(res);
+	cout << endl;
+	}
+
+int TestParser()
+	{
+	Parser p = Parser("A");
+	ParseResult res;
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B");	Print(res);
+
+	p = Parser("A") | Parser("B");
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B");	Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("C");	Print(res);
+
+	p = Parser("A") | Parser("B") | Parser("C");
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B");	Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("C");	Print(res);
+	res = p.Parse("D");	Print(res);
+
+	p = Parser("A") >> Parser("B");
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("BA"); Print(res);
+	res = p.Parse("C"); Print(res);
+
+	p = Parser("A") >> Parser("B") >> Parser("C");
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("ABC"); Print(res);
+	res = p.Parse("ABCD"); Print(res);
+	res = p.Parse("BAC"); Print(res);
+	res = p.Parse("D"); Print(res);
+
+	p = Parser("A") >> Parser("B") >> Parser("A") >> Parser::EOS();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("BA"); Print(res);
+	res = p.Parse("ABA"); Print(res);
+	res = p.Parse("ABAB"); Print(res);
+	res = p.Parse("C"); Print(res);
+
+	p = (Parser("A") | Parser("B")) >> Parser("C");
+	res = p.Parse("A");	Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AC"); Print(res);
+	res = p.Parse("BC"); Print(res);
+	res = p.Parse("BA"); Print(res);
+	res = p.Parse("C"); Print(res);
+	res = p.Parse("CC"); Print(res);
+
+	p = Parser("A") >> (Parser("B") | Parser("BB")) >> Parser::EOS();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("ABB"); Print(res);
+	res = p.Parse("ABBB"); Print(res);
+
+	p = Parser("A") >> (Parser("B") | Parser("C")) >> (Parser("D") | Parser("E")) >> Parser::EOS();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("AC"); Print(res);
+	res = p.Parse("AD"); Print(res);
+	res = p.Parse("AE"); Print(res);
+	res = p.Parse("ABD"); Print(res);
+	res = p.Parse("ABE"); Print(res);
+	res = p.Parse("ACD"); Print(res);
+	res = p.Parse("ACE"); Print(res);
+	res = p.Parse("ADB"); Print(res);
+	res = p.Parse("AEB"); Print(res);
+	res = p.Parse("ADC"); Print(res);
+	res = p.Parse("AEC"); Print(res);
+	res = p.Parse("ABDB"); Print(res);
+	res = p.Parse("ABEC"); Print(res);
+	res = p.Parse("ACDE"); Print(res);
+	res = p.Parse("ACEE"); Print(res);
+
+	p = Parser("A") | Parser("B");
+	Parser q = p >> p;
+	cout << p.Id() << endl;
+	cout << q.Id() << endl;
+	res = q.Parse("A"); Print(res);
+	res = q.Parse("B"); Print(res);
+	res = q.Parse("AA"); Print(res);
+	res = q.Parse("AB"); Print(res);
+	res = q.Parse("BA"); Print(res);
+	res = q.Parse("BB"); Print(res);
+	res = q.Parse("AC"); Print(res);
+	res = q.Parse("CA"); Print(res);
+
+	q = Parser("A") >> p;
+	p = q | Parser::Nul();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AA"); Print(res);
+	res = p.Parse(""); Print(res);
+
+	Parser r = Parser::Nul();
+	q = Parser("A") >> r;
+	r = q | Parser::Nul();
+	p = r >> Parser::EOS();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AA"); Print(res);
+	res = p.Parse("AAB"); Print(res);
+	res = p.Parse(""); Print(res);
+
+	p = Parser("B") >> r >> Parser("B");
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("BB"); Print(res);
+	res = p.Parse("BAB"); Print(res);
+	res = p.Parse("BAAB"); Print(res);
+	res = p.Parse("BAAAB"); Print(res);
+
+	p = r >> Parser("AAB");
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("AAB"); Print(res);
+	res = p.Parse("AAAB"); Print(res);
+	res = p.Parse("AAAAB"); Print(res);
+
+	p = Parser::Int();
+	res = p.Parse("1"); Print(res);
+	res = p.Parse("a"); Print(res);
+	res = p.Parse("123"); Print(res);
+	res = p.Parse("123ab"); Print(res);
+	res = p.Parse(""); Print(res);
+	
+	p = Parser::Real();
+	res = p.Parse("1"); Print(res);
+	res = p.Parse("1.0"); Print(res);
+	res = p.Parse(".01"); Print(res);
+	res = p.Parse("1e9"); Print(res);
+	res = p.Parse("a"); Print(res);
+	res = p.Parse("123"); Print(res);
+	res = p.Parse("123ab"); Print(res);
+	res = p.Parse(""); Print(res);
+	
+
+	// unsupported *
+/*	p = *Parser("A");
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AA"); Print(res);
+	res = p.Parse(""); Print(res);
+
+	p = *Parser("A") >> Parser::EOS();
+	res = p.Parse("A"); Print(res);
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AA"); Print(res);
+	res = p.Parse("AAB"); Print(res);
+	res = p.Parse(""); Print(res);
+
+	p = Parser("B") >> *Parser("A") >> Parser("B");
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("BB"); Print(res);
+	res = p.Parse("BAB"); Print(res);
+	res = p.Parse("BAAB"); Print(res);
+	res = p.Parse("BAAAB"); Print(res);
+
+	p = *Parser("A") >> Parser("AB");
+	res = p.Parse("B"); Print(res);
+	res = p.Parse("AB"); Print(res);
+	res = p.Parse("AAB"); Print(res);
+	res = p.Parse("AAAB"); Print(res);
+	res = p.Parse("AAAAB"); Print(res);
+*/
+	return 0;
+	}
+/*
+Parser p = Parser("A") >> (Parser("B") | Parser("C")) >> (Parser("D") | Parser("E")) >> Parser("F");
+Parser q = p | (p >> q);
+int TestFormulaTreeNode()
+	{
+
+	ParseResult res;
+	res = q.Parse("ACEFACEF");	Print(res);
+	return 0;
+	}
+*/
+// note, uncomment this line to execute test code
+//int x = TestParser();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/CppWriter.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,709 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "CppWriter.h"
+#include "layoutcompilererr.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+#include <cdlcompilertoolkit/cdltkutil.h>
+
+#include <fstream>
+#include <algorithm>
+#include <iostream> // !!! for debug output only
+
+using namespace CdlCompilerToolkit;
+
+string whiteSpace = " \t\r\n";
+
+const string KTextOutputOrder[] = {"C", "l", "r", "B", "W", "J", "Font"};
+const string KTextOutputOrderMirrored[] = {"C", "r", "l", "B", "W", "J", "Font"};
+const int KTextOutputOrderSize = ARRAY_LEN(KTextOutputOrder);
+
+const string KWindowOutputOrder[] = {"C", "l", "t", "r", "b", "W", "H"};
+const string KWindowOutputOrderMirrored[] = {"C", "r", "t", "l", "b", "W", "H"};
+const int KWindowOutputOrderSize = ARRAY_LEN(KWindowOutputOrder);
+
+// class TValuesCppWriter
+void TValuesCppWriter::WriteCpp(ostream& aCpp)
+	{
+	for (TValues::const_iterator it = iValues.begin(); it != iValues.end(); ++it)
+		{
+		if (it != iValues.begin())
+			aCpp << ", ";
+		aCpp << TValues::CppValue(*it);
+		}
+	}
+
+
+// class TLayoutLineCppWriter
+
+void TLayoutLineCppWriter::WriteCpp(ostream& aCpp)
+	{
+	// write line structure
+	WriteLineClassName(aCpp);
+	aCpp << Name() << " = { ";
+	WriteCppData(aCpp);
+	aCpp << " };" << endl << endl;
+	}
+
+
+void TLayoutLineCppWriter::WriteCppData(ostream& aCpp)
+	{
+	if (iLine.iNeedsIndex)
+		WriteVarCppData(aCpp);
+	else
+		WriteFixedCppData(aCpp);
+	}
+
+
+int TLayoutLineCppWriter::WriteParamList(ostream& aLag, const vector<string>& aParams)
+	{
+	int written = 0;
+	if (aParams.size() > 0)
+		{
+		written = 2*aParams.size();
+		aLag << "(";
+		for (vector<string>::const_iterator pParam = aParams.begin(); pParam != aParams.end(); ++pParam)
+			{
+			if (pParam != aParams.begin())
+				aLag << ", ";
+			aLag << *pParam;
+			written += pParam->size();
+			}
+		aLag << ")";
+		}
+	return written;
+	}
+
+int TLayoutLineCppWriter::ValCount()
+	{
+	int count = 0;
+	for (TLayoutLine::const_iterator pVal = iLine.begin(); pVal != iLine.end(); ++pVal)
+		{
+		if (TLayoutTable::IsValueColumn(pVal->first))
+			count += pVal->second.size();
+		}
+	return count;
+	}
+
+
+// class TWindowLineCppWriter
+
+string TWindowLineCppWriter::Name()
+	{
+	if (iLine.iIsUnique)
+		return CdlTkUtil::ToCpp(iLine.Name());
+	else
+		return CdlTkUtil::ToCpp(iLine.TableName());
+	}
+
+void TWindowLineCppWriter::WriteLineClassName(ostream& aCpp)
+	{
+	if (iLine.iNeedsIndex)
+		{
+		aCpp << "const SVarWindowLine<" << ValCount() << "> ";
+		}
+	else
+		{
+		aCpp << "const SFixedWindowLine ";
+		}
+	}
+
+void TWindowLineCppWriter::WriteVarCppData(ostream& aCpp)
+	{
+	aCpp << " { "; // suppress the first offset
+
+	int offset = 0;
+	for (int i=0; i<KWindowOutputOrderSize-1; i++) // Last offset is not used
+		{
+		offset += iLine[KWindowOutputOrder[i]].size();
+		if ( i != 0 ) 
+			aCpp << ", ";
+		aCpp << offset;
+		}
+
+	aCpp << " }, { ";
+
+	WriteFixedCppData(aCpp);
+
+	aCpp << " }";
+	}
+
+void TWindowLineCppWriter::WriteFixedCppData(ostream& aCpp)
+	{
+	for (int i=0; i<KWindowOutputOrderSize; i++)
+		{
+		if (i>0)
+			aCpp << ", ";
+		TValuesCppWriter writer(iLine[KWindowOutputOrder[i]]);
+		writer.WriteCpp(aCpp);
+		}
+	}
+
+void TWindowLineCppWriter::FillParamLists(vector<string>& aDef, vector<string>& aCtor)
+	{
+	if (iLine.iNeedsP)
+		{
+		aDef.push_back(KParamParentRect);
+		aCtor.push_back(KParamParentRect);
+		}
+
+	if (iLine.iNeedsIndex)
+		{
+		aCtor.push_back(CdlTkUtil::IntToString(iLine.iIsMirroredHorizontally));
+
+		for (int i=0; i<KWindowOutputOrderSize; i++)
+			{
+			// need to worry about parameter mirroring here. The problem is that 
+			// the macro needs to have a fixed parameter ordering, but the parameters
+			// might vary between variants, therefore the order of mirrored parameters 
+			// may vary, e.g. (l, t) becomes (t, r) etc. Solution is to swap l and r if the line is mirrored
+			// just for the macro definition (not for the ctor). 
+			string name = KWindowOutputOrder[i];
+			string nameMirrored = KWindowOutputOrderMirrored[i];
+
+			const TValues& defValues = iLine[iLine.iIsMirroredHorizontally ? nameMirrored : name];
+			if (defValues.iNeedsIndex)
+				{
+				string param = CdlTkUtil::ToCpp(defValues.ParamName());
+				if (find(aDef.begin(), aDef.end(), param) == aDef.end()) // param Only written once to Macro
+					{
+					aDef.push_back(param);
+					}
+				}
+
+			const TValues& ctorValues = iLine[name];
+			if (ctorValues.iNeedsIndex)
+				{
+				string param = CdlTkUtil::ToCpp(ctorValues.ParamName());
+				aCtor.push_back(param);
+				}
+			else
+				{
+				aCtor.push_back("0");
+				}
+			}
+		}
+	}
+
+void TWindowLineCppWriter::WriteMacro(ostream& aLag)
+	{
+	vector<string> def_params;
+	vector<string> ctor_params;
+	ctor_params.push_back(CdlTkUtil::IntToString(iLine.iGlobalIndex));
+
+	FillParamLists(def_params, ctor_params);
+
+	aLag << "#define AKN_LAYOUT_WINDOW_" << Name();
+	WriteParamList(aLag, def_params);
+	aLag << "\t" << KTypeWindowLineLayout;		
+	WriteParamList(aLag, ctor_params);
+	aLag << endl;
+	}
+
+
+// class TTextLineCppWriter
+
+string TTextLineCppWriter::Name()
+	{
+	return CdlTkUtil::ToCpp(iLine.TableName());
+	}
+
+void TTextLineCppWriter::FillParamLists(vector<string>& aDef, vector<string>& aCtor)
+	{
+	iBaseLineVariation = false;
+
+	if (iLine.iNeedsP)
+		{
+		aDef.push_back(KParamParentRect);
+		aCtor.push_back(KParamParentRect);
+		}
+
+	if (iLine.iNeedsIndex)
+		{
+		aCtor.push_back(CdlTkUtil::IntToString(iLine.iIsMirroredHorizontally));
+
+		for (int i=0; i<KTextOutputOrderSize; i++)
+			{
+			// need to worry about parameter mirroring here. The problem is that 
+			// the macro needs to have a fixed parameter ordering, but the parameters
+			// might vary between variants, therefore the order of mirrored parameters 
+			// may vary, e.g. (l, t) becomes (t, r) etc. Solution is to swap l and r if the line is mirrored
+			// just for the macro definition (not for the ctor). 
+			string name = KTextOutputOrder[i];
+			string nameMirrored = KTextOutputOrderMirrored[i];
+
+			const TValues& defValues = iLine[iLine.iIsMirroredHorizontally ? nameMirrored : name];
+			if (defValues.iNeedsIndex)
+				{
+				string param = CdlTkUtil::ToCpp(defValues.ParamName());
+				if (find(aDef.begin(), aDef.end(), param) == aDef.end()) // uniqueness check
+					{
+					aDef.push_back(param);
+					}
+
+				// record whether some of the variation comes from the Baseline column
+				if ( defValues.iName == "B")
+					iBaseLineVariation = true;	
+				}
+
+			const TValues& ctorValues = iLine[name];
+			if (ctorValues.iNeedsIndex)
+				{
+				string param = CdlTkUtil::ToCpp(ctorValues.ParamName());
+				aCtor.push_back(param);
+				}
+			else
+				{
+				aCtor.push_back("0");
+				}
+			}
+		}
+	}
+
+void TTextLineCppWriter::WriteMacro(ostream& aLag)
+	{
+	vector<string> def_params;
+	vector<string> ctor_params;
+	ctor_params.push_back(CdlTkUtil::IntToString(iLine.iGlobalIndex));
+
+	FillParamLists(def_params, ctor_params);
+
+	aLag << "#define AKN_LAYOUT_TEXT_" << Name();
+	WriteParamList(aLag, def_params);
+	aLag << "\t" << KTypeTextLineLayout;
+	WriteParamList(aLag, ctor_params);
+	aLag << endl;
+
+// Also write out a multiline_text if there are more than one Baselines supplied.  Number of lines is always user-supplied
+	vector<string> multiline_def_params;
+	vector<string> multiline_ctor_params;
+
+	if ( iBaseLineVariation )
+		{
+		multiline_ctor_params.push_back(CdlTkUtil::IntToString(iLine.iGlobalIndex));
+
+		if (iLine.iNeedsP)
+			{
+			multiline_def_params.push_back(KParamParentRect);
+			multiline_ctor_params.push_back(KParamParentRect);
+			}
+
+		if (iLine.iNeedsIndex) // this condition has already been tested when setting iBaseLineVariation, but check again here for completeness
+			{
+			multiline_ctor_params.push_back(CdlTkUtil::IntToString(iLine.iIsMirroredHorizontally));
+			}
+
+			for (int i=0; i<KTextOutputOrderSize; i++)
+				{
+				// need to worry about parameter mirroring here. The problem is that 
+				// the macro needs to have a fixed parameter ordering, but the parameters
+				// might vary between variants, therefore the order of mirrored parameters 
+				// may vary, e.g. (l, t) becomes (t, r) etc. Solution is to swap l and r if the line is mirrored
+				// just for the macro definition (not for the ctor). 
+				string name = KTextOutputOrder[i];
+				string nameMirrored = KTextOutputOrderMirrored[i];
+
+				const TValues& defValues = iLine[iLine.iIsMirroredHorizontally ? nameMirrored : name];
+				if (defValues.iNeedsIndex) 
+					{
+					if (defValues.iName != "B") 
+						{
+						string param = CdlTkUtil::ToCpp(defValues.ParamName());
+						if (find(multiline_def_params.begin(), multiline_def_params.end(), param) == multiline_def_params.end())
+							{
+							multiline_def_params.push_back(param);
+							}
+// A variable parameter that is tied to the baseline is NOT suppressed in the Multiline
+// You have to supply the parameter in the macro as a zero
+						}
+					}
+
+				const TValues& ctorValues = iLine[name];
+				if (ctorValues.iNeedsIndex)
+					{
+					if (defValues.iName != "B") 
+						{
+						string param = CdlTkUtil::ToCpp(ctorValues.ParamName());
+						multiline_ctor_params.push_back(param);
+// A variable parameter that is tied to the baseline is NOT suppressed in the Multiline
+// You have to supply the parameter in the macro as a zero
+						}
+					else
+						{
+						multiline_ctor_params.push_back("0");
+						}
+					}
+				else
+					{
+					multiline_ctor_params.push_back("0");
+					}
+
+				} // end of for loop
+
+		// The final param for the multiline macro is user input for the layout utilities (pass-through data)
+		multiline_def_params.push_back(KParamNameNumberOfLinesShown);
+		multiline_ctor_params.push_back(KParamNameNumberOfLinesShown);
+
+		aLag << "#define AKN_LAYOUT_MULTILINE_TEXT_" << Name();
+		WriteParamList(aLag, multiline_def_params);
+		aLag << "\t" + KTypeMultiLineTextLayout;
+		WriteParamList(aLag, multiline_ctor_params);
+		aLag << endl;
+		} // end of if on baseline_variation
+	}
+
+
+void TTextLineCppWriter::WriteLineClassName(ostream& aCpp)
+	{
+	if (iLine.iNeedsIndex)
+		{
+		aCpp << "const SVarTextLine<" << ValCount()  << "> ";
+		}
+	else
+		{
+		aCpp << "const SFixedTextLine ";
+		}
+	}
+
+void TTextLineCppWriter::WriteVarCppData(ostream& aCpp)
+	{
+	aCpp << " { ";  // ! Do not write out the first 0
+
+	int offset = 0;
+	for (int i=0; i<KTextOutputOrderSize-1; i++) // last offset IS used because font id is written out
+		{
+		offset += iLine[KTextOutputOrder[i]].size();
+		if ( i != 0 )
+			aCpp << ", "; 
+		aCpp << offset;
+		}
+
+	aCpp << " }, { ";
+
+	WriteFixedCppData(aCpp);
+
+	aCpp << " }";
+	}
+
+void TTextLineCppWriter::WriteFixedCppData(ostream& aCpp)
+	{
+	for (int i=0; i<KTextOutputOrderSize; i++)
+		{
+		if ( i > 0 )
+			aCpp << ", ";
+		TValuesCppWriter writer(iLine[KTextOutputOrder[i]]);
+		writer.WriteCpp(aCpp);
+		}
+	}
+
+void TTextLineCppWriter::WriteMultiLineTextParamList(ostream& aLag, const vector<string>& aParams)
+	{
+	if (aParams.size() > 0)
+		{
+		aLag << "(";
+		for (vector<string>::const_iterator pParam = aParams.begin(); pParam != aParams.end(); ++pParam)
+			{
+			if (pParam != aParams.begin())
+				aLag << ", ";
+			aLag << *pParam;
+			}
+		aLag << ", " << KParamNameNumberOfLinesShown;
+		aLag << ")";
+		}
+	}
+
+
+// class TLayoutTableCppWriter
+
+void TLayoutTableCppWriter::WriteCppLineData(ostream& aCpp)
+	{
+	for (TLayoutTable::iterator it = iTable.begin(); it != iTable.end(); ++it)
+		{
+		TLayoutLineCppWriter* writer = CreateLayoutLineCppWriter(**it, iTable);
+		writer->WriteCpp(aCpp);
+		delete writer;
+		}
+	}
+
+void TLayoutTableCppWriter::WriteCppTableData(ostream& aCpp)
+	{
+	}
+
+void TLayoutTableCppWriter::WriteLag(ostream& aLag)
+	{
+	aLag << endl;
+	int count=0;
+	for (TLayoutTable::TLayoutSubTables::iterator it = iTable.iSubTables.begin(); it != iTable.iSubTables.end(); ++it)
+		{
+		WriteLagSubTable(**it, count++, aLag);
+		}
+	}
+
+
+void TLayoutTableCppWriter::WriteLagSubTable(const TLayoutTable::TLayoutSubTable& aSubTable, int aCount, ostream& aLag)
+	{
+	// normal version
+	string macro = "#define AKN_LAYOUT_TABLE_";
+	macro = macro + CdlTkUtil::ToCpp(iTable.Name());
+	if (aSubTable.size() != iTable.size())
+		{
+		macro = macro + "_SUB_TABLE_" + CdlTkUtil::IntToString(aCount);
+		aLag << "// Sub table for " << iTable.Name() << ". Valid line indices are ";
+		for (TLayoutTable::TLayoutSubTable::const_iterator pNum = aSubTable.begin(); pNum != aSubTable.end(); ++pNum)
+			{
+			if (pNum != aSubTable.begin())
+				aLag << ", ";
+			aLag << CdlTkUtil::IntToString(*pNum);
+			}
+		aLag << endl;
+		}
+
+	aLag << macro;
+
+	int lineSet = 0;
+	for (TLayoutTable::TLayoutSubTable::const_iterator pNum = aSubTable.begin(); pNum != aSubTable.end(); ++pNum)
+		{
+		if (*pNum < 32)
+			lineSet |= (1 << *pNum);
+		}
+
+	vector<string> def_params;
+	def_params.push_back(KParamLineIndex);
+	vector<string> ctor_params;
+	ctor_params.push_back(CdlTkUtil::IntToString(iTable.iFirstLineGlobalIndex));
+	ctor_params.push_back(KParamLineIndex);
+	ctor_params.push_back(CdlTkUtil::IntToHexString(lineSet));
+
+	TLayoutLineCppWriter* writer = CreateLayoutLineCppWriter(*iTable[aSubTable[0]], iTable);
+	writer->FillParamLists(def_params, ctor_params);
+	int paramSize = writer->WriteParamList(aLag, def_params);
+
+	// some maths to make bigger tabulation
+	int numTabs = 6-(((paramSize+macro.size())/4)%6);
+	for (int i=0; i<numTabs; i++)
+		aLag << "\t";
+
+	if (iTable.iType == TLayoutTable::EWindowTable)
+		aLag << KTypeWindowLineLayout;
+	else
+		aLag << KTypeTextLineLayout;
+	writer->WriteParamList(aLag, ctor_params);
+	aLag << endl;
+
+	delete writer;
+	}
+
+TLayoutLineCppWriter* TLayoutTableCppWriter::CreateLayoutLineCppWriter(TLayoutLine& aLine, TLayoutTable& aTable)
+	{
+	if (aTable.iType == TLayoutTable::EWindowTable)
+		return new TWindowLineCppWriter(aLine);
+	else
+		return new TTextLineCppWriter(aLine);
+	}
+
+
+// class TLayoutCppWriter
+
+void TLayoutCppWriter::WriteCppLineData(ostream& aCpp)
+	{
+	for (TLayout::iterator it = iLayout.begin(); it != iLayout.end(); ++it)
+		{
+		TLayoutTableCppWriter writer(**it);
+		writer.WriteCppLineData(aCpp);
+		}
+	}
+
+void TLayoutCppWriter::WriteCppTableData(ostream& aCpp)
+	{
+	}
+
+void TLayoutCppWriter::WriteLag(ostream& aLag)
+	{
+	aLag << endl << endl << "// Layout MACROs for indexed table access" << endl;
+	// write the macros
+	for (TLayout::iterator it = iLayout.begin(); it != iLayout.end(); ++it)
+		{
+		TLayoutTable& table = **it;
+		if (table.IsWorthATableIndex())
+			{
+			TLayoutTableCppWriter writer(table);
+			writer.WriteLag(aLag);
+			}
+		}
+
+	aLag << endl << "#endif " << endl;
+	}
+
+
+// class TLayoutLineTable
+
+void TLayoutLineTable::WriteCpp(ostream& aCpp)
+	{
+	aCpp << "const TAny* const KTheLineTable[] =" << endl << "\t{" << endl << "\t";
+	int index = 0;
+	for (iterator it = begin(); it != end(); ++it)
+		{
+		TLayoutLine& line = **it;
+		TLayoutTable& table = *line.iTable;
+		if (table.iFirstLineGlobalIndex == -1)
+			table.iFirstLineGlobalIndex = index;
+		TLayoutLineCppWriter* writer = TLayoutTableCppWriter::CreateLayoutLineCppWriter(line, table);
+		if (it != begin())
+			aCpp << "," << endl << "\t";
+		aCpp << "&" << writer->Name();
+		delete writer;
+		index++;
+		}
+	aCpp << endl << "\t};" << endl;
+	}
+
+void TLayoutLineTable::WriteLag(ostream& aLag)
+	{
+	string current_table_name = "";
+
+	for (iterator it = begin(); it != end(); ++it)
+		{
+		TLayoutLine& line = **it;
+
+		if ( current_table_name != line.iTable->Name() )
+			{
+			aLag << endl << "//" << " Layout MACROs for LAF Table : " << line.iTable->Name() << endl ;
+			current_table_name = line.iTable->Name();
+			}
+
+		TLayoutLineCppWriter* writer = TLayoutTableCppWriter::CreateLayoutLineCppWriter(line, *line.iTable);
+		writer->WriteMacro(aLag);
+		delete writer;
+		}
+	}
+
+
+// class TLayoutLineTable
+
+TCppWriter::TCppWriter(TLayout& aLayout, const std::string& aName)
+: TLayWriterBase(aLayout, aName)
+	{
+	}
+
+void TCppWriter::Write(const std::string& aLayName)
+	{
+	std::string lay = aLayName.substr(aLayName.find_last_of('\\')+1);
+	lay = lay.substr(0, lay.find_first_of('.'));
+
+	iShortName = iName.substr(iName.find_last_of('\\')+1);
+	iName = iName.substr(0, iName.find_first_of('.')) + lay;
+
+	BuildLayoutLineTable();
+	CCdlTkFileCleanup temp(iName+".lag");
+	Output(iName+".cpp", iName+".lag", lay);
+	CdlTkUtil::ExportFile(temp, KDirEpocSysHeader+iShortName+".lag");
+	}
+
+void TCppWriter::Output(const string& aCpp, const string& aLag, const string& aLayName)
+	{
+	cout << "writing cpp " << aCpp << endl;
+	ofstream cpp(aCpp.c_str());
+	WriteCppHeader(cpp);
+	TLayoutCppWriter writer(iLayout);
+	writer.WriteCppLineData(cpp);
+	iLineTable.WriteCpp(cpp);
+	writer.WriteCppTableData(cpp);
+	WriteCppFooter(cpp, aLayName);
+	cpp.close();
+
+	cout << "writing header " << aLag << endl;
+	ofstream lag(aLag.c_str());
+	WriteLagHeader(lag);
+	iLineTable.WriteLag(lag);
+	writer.WriteLag(lag);
+	lag.close();
+	}
+
+void TCppWriter::BuildLayoutLineTable()
+	{
+	int globalIndex = 0;
+	for (TLayout::const_iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		for (TLayoutTable::const_iterator pLine = (*pTab)->begin(); pLine != (*pTab)->end(); ++pLine)
+			{
+			(*pLine)->iGlobalIndex = globalIndex++;
+			iLineTable.push_back(*pLine);
+			}
+		}
+	}
+
+void TCppWriter::WriteCppHeader(ostream& aCpp)
+	{
+	aCpp << "/*" << endl;
+	aCpp << "* ============================================================================" << endl;
+	aCpp << "*  Name     : " << iShortName << ".cpp" << endl;
+	aCpp << "*  Part of  : Avkon" << endl;
+	aCpp << "*" << endl;
+	aCpp << "*  Description: This file is automatically generated layout data file." << endl;
+	aCpp << "*" << endl;
+	aCpp << "*  Version  :" << endl;
+	aCpp << "*" << endl;
+	aCpp << "*  Copyright © 2002-2004 Nokia Corporation." << endl;
+	aCpp << "*  This material, including documentation and any related" << endl;
+	aCpp << "*  computer programs, is protected by copyright controlled by" << endl;
+	aCpp << "*  Nokia Corporation. All rights are reserved. Copying,"<< endl;
+	aCpp << "*  including reproducing, storing,  adapting or translating, any" << endl;
+	aCpp << "*  or all of this material requires the prior written consent of" << endl;
+	aCpp << "*  Nokia Corporation. This material also contains confidential" << endl;
+	aCpp << "*  information which may not be disclosed to others without the" << endl;
+	aCpp << "*  prior written consent of Nokia Corporation." << endl;
+	aCpp << "* ============================================================================" << endl;
+	aCpp << "*/" << endl  << endl;
+	aCpp << "#include \"aknlayoutdatadef.h\"" << endl << endl;
+	}
+
+void TCppWriter::WriteCppFooter(ostream& aCpp, const string& aLayName)
+	{
+	aCpp << endl << "const TAny* GetData_" << aLayName << "(" << KTypeInt << " aLineId) { return KTheLineTable[aLineId]; }" << endl;
+	}
+
+void TCppWriter::WriteLagHeader(ostream& aLag)
+	{
+	aLag << "/*" << endl;
+	aLag << "* ============================================================================" << endl;
+	aLag << "*  Name     : " << iShortName << ".lag" << endl;
+	aLag << "*  Part of  : Avkon" << endl;
+	aLag << "*" << endl;
+	aLag << "*  Description: This file is automatically generated layout file." << endl;
+	aLag << "*" << endl;
+	aLag << "*  Version  :" << endl;
+	aLag << "*" << endl;
+	aLag << "*  Copyright © 2002-2004 Nokia Corporation." << endl;
+	aLag << "*  This material, including documentation and any related" << endl;
+	aLag << "*  computer programs, is protected by copyright controlled by" << endl;
+	aLag << "*  Nokia Corporation. All rights are reserved. Copying,"<< endl;
+	aLag << "*  including reproducing, storing,  adapting or translating, any" << endl;
+	aLag << "*  or all of this material requires the prior written consent of" << endl;
+	aLag << "*  Nokia Corporation. This material also contains confidential" << endl;
+	aLag << "*  information which may not be disclosed to others without the" << endl;
+	aLag << "* ============================================================================" << endl;
+	aLag << "*/" << endl  << endl;
+	aLag << "#if !defined(__" << iShortName << "_LAG__)" << endl;
+	aLag << "#define __" << iShortName << "_LAG__" << endl;
+	aLag << "#include <aknlayoutdef.h>" << endl << endl;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Extract.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include "Extract.h"
+#include "LayoutCompilerErr.h"
+#include "HtmlParse.h"
+#include "LayoutParse.h"
+#include "LayoutWriter.h"
+#include <fstream>
+#include <iostream>
+
+typedef LayoutProcessArgsErr<LayoutExtract> LayoutExtractArgsErr;
+
+
+int LayoutExtract::Extract(const vector<string>& args)
+	{
+	ParseArgs(args);
+
+	THtmlParseLayout html;
+	ifstream in(iDocName.c_str());
+	if (!in.is_open())
+		throw NotFoundErr(iDocName);
+	cout << "reading html " << iDocName << endl;
+	html.Parse(in);
+	in.close();
+
+	TLayout* layout = &html;
+	TLayParseLayout lay;
+	if (iMergeName.size())
+		{
+		ifstream merge(iMergeName.c_str());
+		if (!merge.is_open())
+			throw NotFoundErr(iDocName);
+		cout << "reading layout " << iMergeName << endl;
+		lay.Parse(merge);
+		merge.close();
+
+		cout << "merging " << iDocName << " into " << iMergeName << endl;
+		lay.Merge(TLayout::KMergeModeMerge, html);
+		layout = &lay;
+		}
+
+	TLayoutWriter writer(*layout, iLayoutName);
+	writer.Write("");
+
+	return 0;
+	}
+
+void LayoutExtract::ParseArgs(const vector<string>& args)
+	{
+	if (args.size() < 4)
+		throw LayoutExtractArgsErr();
+
+	iDocName = args[2];
+
+	int layoutIndex = 3;
+	if (args[3][0] == '-')
+		{
+		if (args[3].size() < 3 || args[3][1] != 'o')
+			throw LayoutExtractArgsErr();
+
+		iMergeName = args[3].substr(2);
+		layoutIndex++;
+		}
+
+	if (args.size() <= layoutIndex)
+		throw LayoutExtractArgsErr();
+
+	iLayoutName = args[layoutIndex];
+	}
+
+void LayoutExtract::ShowHelp(ostream& stream)
+	{
+	stream << endl;
+	stream << "LayoutCompiler extract <docName> [-o<oldLayout>] <layoutName>" << endl;
+	stream << "  <docName> is the name of the HTML Layout specification" << endl;
+	stream << "  <oldLayout> is an optional layout file which the extracted layout will be" << endl;
+	stream << "  merged with" << endl;
+	stream << "  <layoutName> is the name of the resulting layout file" << endl;
+	stream << "  You can use the same name for <oldLayout> and <layoutName>" << endl;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/FormulaParser.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,150 @@
+/*
+* 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 "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:
+*
+*/
+#include "FormulaParser.h"
+
+
+ParseResult ParseFormula(const string& aFormula)
+	{
+	Parser cell_nameParser = Parser("B") | Parser("H") | Parser("L") | Parser("R") | Parser("T") | Parser("W") | Parser("b") | Parser("h") | Parser("l") | Parser("r") | Parser("t") | Parser("w");
+	cell_nameParser.SetId(cell_name_ParserId);
+	Parser parentParser = Parser("P");
+	parentParser.SetId(parent_ParserId);
+	Parser parent_cellParser = parentParser >> Parser("_") >> cell_nameParser;
+	parent_cellParser.SetId(parent_cell_ParserId);
+	Parser table_cellParser = Parser::Real();
+	table_cellParser.SetId(table_cell_ParserId);
+	Parser comp_cellParser = Parser::Real() >> Parser("_") >> cell_nameParser;
+	comp_cellParser.SetId(comp_cell_ParserId);
+	Parser abs_cellParser = 
+		Parser("$") >> 
+		Parser::Real() >> 
+		Parser("!") >> 
+		Parser::Real() >> 
+		Parser("!") >> 
+		cell_nameParser >> 
+		Parser("!$");
+	abs_cellParser.SetId(abs_cell_ParserId);
+
+	// types of value
+	Parser cellParser = 
+		cell_nameParser | 
+		parent_cellParser | 
+		parentParser | 
+		comp_cellParser | 
+		abs_cellParser | 
+		table_cellParser;
+
+	Parser unitsParser = 
+		Parser::Real() >> 
+		(Parser("u") | Parser("U"));
+	unitsParser.SetId(units_ParserId);
+
+	Parser constantParser = 
+		Parser::Real() >> 
+		Parser("p");
+	constantParser.SetId(constant_ParserId);
+
+	Parser attributeParser = 
+		Parser("pr") >> 
+		Parser::Int();
+	attributeParser.SetId(attribute_ParserId);
+
+	Parser mysteryParser = 
+		Parser::Int() >> 
+		Parser("pr") >> 
+		Parser::Int();
+	mysteryParser.SetId(mystery_ParserId);
+
+	// functions
+	Parser expressionParser;
+	Parser func_nameParser = Parser("CEIL") | Parser("FLOOR") | Parser("ROUND");
+	Parser funcParser = func_nameParser >> Parser("(") >> expressionParser >> Parser(")");
+	funcParser.SetId(func_ParserId);
+
+	Parser valueParser = 
+		unitsParser | 
+		mysteryParser | 
+		attributeParser | 
+		constantParser | 
+		funcParser | 
+		cellParser ;
+
+	// arithmetic expressions from boost spirit library example
+	Parser groupParser = Parser("(") >> expressionParser >> Parser(")");
+	groupParser.SetId(group_ParserId);
+	Parser factorParser = valueParser | groupParser;
+
+	Parser termExtStarParser;
+	Parser termExtParser = 
+		((Parser("*") >> factorParser) | 
+		 (Parser("/") >> factorParser)) >>
+		termExtStarParser;
+	termExtStarParser = termExtParser | Parser::Nul();
+
+	Parser termParser = 
+		factorParser >> 
+		termExtStarParser;
+	termParser.SetId(term_ParserId);
+
+	Parser expressionExtStarParser;
+	Parser expressionExtParser = 
+		((Parser("+") >> termParser) | 
+		 (Parser("-") >> termParser)) >>
+		expressionExtStarParser;
+	expressionExtStarParser = expressionExtParser | Parser::Nul();
+
+	expressionParser = 
+		termParser >> 
+		expressionExtStarParser;
+	expressionParser.SetId(expression_ParserId);
+
+	// comparisons
+	Parser comp_opParser = Parser(">=") | Parser("<=") | Parser("=") | Parser(">") | Parser("<");
+
+	Parser whitespaceParser;
+	Parser compParser = 
+		expressionParser >> 
+		whitespaceParser >> 
+		comp_opParser >> 
+		whitespaceParser >> 
+		expressionParser;
+	compParser.SetId(comp_ParserId);
+
+	Parser comp_groupParser = Parser("(") >> compParser >> Parser(")");
+	comp_groupParser.SetId(comp_group_ParserId);
+	Parser compOptParser = compParser | comp_groupParser;
+
+	// conditionals
+	Parser conditionalParser = 
+		Parser("IF ") >> 
+		compOptParser >> 
+		Parser(" THEN ") >> 
+		expressionParser >> 
+		Parser(" ELSE ") >> 
+		expressionParser;
+	conditionalParser.SetId(conditional_ParserId);
+
+
+	Parser whitespaceExtParser = Parser(" ") >> whitespaceParser;
+	whitespaceParser = whitespaceExtParser | Parser::Nul();
+
+	// formula
+	Parser formulaParser = conditionalParser | expressionParser;
+
+
+	return formulaParser.Parse(aFormula);
+	}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/FormulaTree.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,306 @@
+/*
+* 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 "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:
+*
+*/
+#include "FormulaTree.h"
+#include "FormulaParser.h"
+#include <sstream>
+#include <iostream>
+using namespace std;
+
+FormulaTreeNode* FormulaTreeNode::Parse(const string& aFormula)
+	{
+	return NewTree(ParseFormula(aFormula), aFormula);
+	}
+
+FormulaTreeNode::~FormulaTreeNode()
+	{
+	for (int i=0; i<Size(); i++)
+		delete iSubNodes[i];
+	}
+
+int FormulaTreeNode::Size() const
+	{
+	return iSubNodes.size();
+	}
+
+FormulaTreeNode& FormulaTreeNode::operator[](int aIndex)
+	{
+	return *iSubNodes[aIndex];
+	}
+
+const FormulaTreeNode& FormulaTreeNode::operator[](int aIndex) const
+	{
+	return *iSubNodes[aIndex];
+	}
+
+FormulaTreeNode::TNodeType FormulaTreeNode::Type() const
+	{
+	return iType;
+	}
+
+string FormulaTreeNode::Text() const
+	{
+	return iSource.substr(iStart, iLen);
+	}
+
+char FormulaTreeNode::Char() const
+	{
+	return iSource[iStart];
+	}
+
+int FormulaTreeNode::Int() const
+	{
+	int r;
+	stringstream(Text()) >> r;
+	return r;
+	}
+
+double FormulaTreeNode::Real() const
+	{
+	double r;
+	stringstream(Text()) >> r;
+	return r;
+	}
+
+FormulaTreeNode* FormulaTreeNode::NewTree(const ParseResult& aParse, const string& aFormula)
+	{
+	FormulaTreeNode* node = 0;
+
+	int parseId = aParse.iRuleId;
+	if (parseId == cell_name_ParserId)
+		{
+		node = new FormulaTreeNode(ECell, aFormula, aParse.iStart, aParse.iEnd-aParse.iStart);
+		}
+	else if (parseId == parent_ParserId)
+		{
+		node = new FormulaTreeNode(EParent, aFormula, aParse.iStart, aParse.iEnd-aParse.iStart);
+		}
+	else if (parseId == parent_cell_ParserId)
+		{
+		const ParseResult& cell = aParse.iChildren[1];
+		node = new FormulaTreeNode(EParentCell, aFormula, cell.iStart, cell.iEnd-cell.iStart);
+		}
+	else if (parseId == table_cell_ParserId)
+		{
+		node = new FormulaTreeNode(ETableCell, aFormula, aParse.iStart, aParse.iEnd-aParse.iStart);
+		}
+	else if (parseId == comp_cell_ParserId)
+		{
+		const ParseResult& cellId = aParse.iChildren[0].iChildren[0];
+		node = new FormulaTreeNode(EComponent, aFormula, cellId.iStart, cellId.iEnd-cellId.iStart);
+		node->iSubNodes.push_back(NewTree(aParse.iChildren[1], aFormula));
+		}
+	else if (parseId == abs_cell_ParserId)
+		{
+		node = new FormulaTreeNode(EAbsolute, aFormula, aParse.iStart, aParse.iEnd-aParse.iStart);
+		const ParseResult& part1 = aParse.iChildren[0].iChildren[0].iChildren[0].iChildren[0].iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(new FormulaTreeNode(EReal, aFormula, part1.iStart, part1.iEnd-part1.iStart));
+		const ParseResult& part2 = aParse.iChildren[0].iChildren[0].iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(new FormulaTreeNode(EReal, aFormula, part2.iStart, part2.iEnd-part2.iStart));
+		const ParseResult& part3 = aParse.iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(NewTree(part3, aFormula));
+		}
+	else if (parseId == units_ParserId)
+		{
+		const ParseResult& units = aParse.iChildren[0];
+		node = new FormulaTreeNode(EUnits, aFormula, units.iStart, units.iEnd-units.iStart);
+		}
+	else if (parseId == constant_ParserId)
+		{
+		const ParseResult& constant = aParse.iChildren[0];
+		node = new FormulaTreeNode(EConstant, aFormula, constant.iStart, constant.iEnd-constant.iStart);
+		}
+	else if (parseId == attribute_ParserId)
+		{
+		const ParseResult& attrib = aParse.iChildren[1];
+		node = new FormulaTreeNode(EAttribute, aFormula, attrib.iStart, attrib.iEnd-attrib.iStart);
+		}
+	else if (parseId == mystery_ParserId)
+		{
+		node = new FormulaTreeNode(EMystery, aFormula, aParse.iStart, aParse.iEnd-aParse.iStart);
+		const ParseResult& part1 = aParse.iChildren[0].iChildren[0];
+		node->iSubNodes.push_back(new FormulaTreeNode(EInt, aFormula, part1.iStart, part1.iEnd-part1.iStart));
+		const ParseResult& part2 = aParse.iChildren[1];
+		node->iSubNodes.push_back(new FormulaTreeNode(EInt, aFormula, part2.iStart, part2.iEnd-part2.iStart));
+		}
+	else if (parseId == func_ParserId)
+		{
+		const ParseResult& funcName = aParse.iChildren[0].iChildren[0].iChildren[0];
+		node = new FormulaTreeNode(EFunction, aFormula, funcName.iStart, funcName.iEnd-funcName.iStart);
+		const ParseResult& expr= aParse.iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(NewTree(expr, aFormula));
+		}
+	else if (parseId == group_ParserId)
+		{
+		node = NewTree(aParse.iChildren[0].iChildren[1], aFormula);
+		}
+	else if (parseId == term_ParserId || parseId == expression_ParserId)
+		{
+		node = NewTree(aParse.iChildren[0], aFormula);
+		const ParseResult* parse = &aParse;
+		while (parse->iChildren[1].iChildren[0].iRuleId != Parser::Nul().Id())
+			{
+			const ParseResult& oper = parse->iChildren[1].iChildren[0].iChildren[0].iChildren[0].iChildren[0];
+			FormulaTreeNode* newNode = new FormulaTreeNode(EArithmetic, aFormula, oper.iStart, oper.iEnd-oper.iStart);
+			newNode->iSubNodes.push_back(node);
+			const ParseResult& right = parse->iChildren[1].iChildren[0].iChildren[0].iChildren[0].iChildren[1];
+			newNode->iSubNodes.push_back(NewTree(right, aFormula));
+			node = newNode;
+			parse = &parse->iChildren[1].iChildren[0];
+			}
+		}
+	else if (parseId == comp_group_ParserId)
+		{
+		node = NewTree(aParse.iChildren[0].iChildren[1], aFormula);
+		}
+	else if (parseId == comp_ParserId)
+		{
+		const ParseResult& oper = aParse.iChildren[0].iChildren[0].iChildren[1];
+		node = new FormulaTreeNode(ECondition, aFormula, oper.iStart, oper.iEnd-oper.iStart);
+		const ParseResult& lhs = aParse.iChildren[0].iChildren[0].iChildren[0].iChildren[0];
+		node->iSubNodes.push_back(NewTree(lhs, aFormula));
+		const ParseResult& rhs = aParse.iChildren[1];
+		node->iSubNodes.push_back(NewTree(rhs, aFormula));
+		}
+	else if (parseId == conditional_ParserId)
+		{
+		node = new FormulaTreeNode(EConditional, aFormula, aParse.iStart, 0);
+		const ParseResult& cond = aParse.iChildren[0].iChildren[0].iChildren[0].iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(NewTree(cond, aFormula));
+		const ParseResult& thenExpr = aParse.iChildren[0].iChildren[0].iChildren[1];
+		node->iSubNodes.push_back(NewTree(thenExpr, aFormula));
+		const ParseResult& elseExpr = aParse.iChildren[1];
+		node->iSubNodes.push_back(NewTree(elseExpr, aFormula));
+		}
+	else	// internal alt node, recurse down
+		{
+		node = NewTree(aParse.iChildren[0], aFormula);
+		}
+
+	return node;
+	}
+
+FormulaTreeNode::FormulaTreeNode(TNodeType aType, const string& aSource, int aStart, int aLen)
+: iSource(aSource), iStart(aStart), iLen(aLen), iType(aType)
+	{
+	}
+
+FormulaTreeNode::FormulaTreeNode(const FormulaTreeNode& aOther)
+: iSource(aOther.iSource), iStart(aOther.iStart), iLen(aOther.iLen), iType(aOther.iType)
+	{
+	for (int i=0; i<iSubNodes.size(); i++)
+		delete iSubNodes[i];
+	iSubNodes.clear();
+	for (int j=0; j<aOther.iSubNodes.size(); j++)
+		iSubNodes.push_back(new FormulaTreeNode(*aOther.iSubNodes[j]));
+	}
+
+void FormulaTreeNode::Print(const FormulaTreeNode& aNode)
+	{
+	switch (aNode.Type())
+		{
+		case FormulaTreeNode::EReal:		// Double() = the number
+			cout << aNode.Real();
+			break;
+		case FormulaTreeNode::EInt:			// Int() = the number
+			cout << aNode.Int();
+			break;
+		case FormulaTreeNode::ECell:			// Char() = cell name
+			cout << aNode.Char();
+			break;
+		case FormulaTreeNode::EParent:		// nothing special
+			cout << aNode.Char();
+			break;
+		case FormulaTreeNode::EParentCell:	// Char() = parent cell name
+			cout << "P_" << aNode.Char();
+			break;
+		case FormulaTreeNode::ETableCell:		// Double() = target table
+			cout << aNode.Real();
+			break;
+		case FormulaTreeNode::EComponent:		// Double() = component id, [0] = cell name
+			cout << aNode.Real() << "_";
+			Print(aNode[0]);
+			break;
+		case FormulaTreeNode::EAbsolute:		// Text() = whole thing, [0], [1] = real components, [2] = cell name
+			cout << "Abs(";
+			Print(aNode[0]);
+			cout << ",";
+			Print(aNode[1]);
+			cout << ",";
+			Print(aNode[2]);
+			cout << ")";
+			break;
+		case FormulaTreeNode::EUnits:			// Double() = units
+			cout << aNode.Real() << "units";
+			break;
+		case FormulaTreeNode::EConstant:		// Double() = constant
+			cout << "const(" << aNode.Real() << ")";
+			break;
+		case FormulaTreeNode::EAttribute:		// Int() = attribute
+			cout << "attrib(" << aNode.Int() << ")";
+			break;
+		case FormulaTreeNode::EMystery:		// Text() = whole thing, [0], [1] = int components
+			cout << "mystery(";
+			Print(aNode[0]);
+			cout << ",";
+			Print(aNode[1]);
+			cout << ")";
+			break;
+		case FormulaTreeNode::EFunction:		// Text() = function name, [0] = parameter
+			cout << aNode.Text() << "(";
+			Print(aNode[0]);
+			cout << ")";
+			break;
+		case FormulaTreeNode::EArithmetic:	// Char() = arithmetic operator, [0], [1] = sub expressions
+			cout << aNode.Char() << "(";
+			Print(aNode[0]);
+			cout << ",";
+			Print(aNode[1]);
+			cout << ")";
+			break;
+		case FormulaTreeNode::ECondition:		// Text() = comparison operator, [0], [1] = sub expressions
+			cout << aNode.Text() << "(";
+			Print(aNode[0]);
+			cout << ",";
+			Print(aNode[1]);
+			cout << ")";
+			break;
+		case FormulaTreeNode::EConditional:	// no content, [0] = condition, [1] = then expression, [2] = else expression
+			cout << "IF ";
+			Print(aNode[0]);
+			cout << " THEN ";
+			Print(aNode[1]);
+			cout << " ELSE ";
+			Print(aNode[2]);
+			break;
+		};
+	}
+
+void Print(const ParseResult& res);
+
+
+int TestFormulaTreeNode()
+	{
+	string formula("IF (P_W/25p*4.25p) <= P_H THEN P_W/25p*4.25p ELSE P_H");
+//	string formula("1*2/3");
+	Print(ParseFormula(formula));
+	FormulaTreeNode* tree = FormulaTreeNode::Parse(formula);
+	FormulaTreeNode::Print(*tree);
+	delete tree;
+	return 0;
+	}
+
+// int x = TestFormulaTreeNode()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/HtmlParse.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,668 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "HtmlParse.h"
+#include <iostream>
+#include <sstream>
+#include <set>
+#include <algorithm>
+using namespace std;
+
+
+const string WhiteSpace(" \t\r\n");
+const string gValidText("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_<>()-+. ");
+const string gValidNum("0123456789+-p ,");
+const string KEllipsis("\205");
+const string KUnknown("unknown");
+
+string TrimWhiteSpace(const string& aString)
+	{
+	int start = aString.find_first_not_of(WhiteSpace);
+	if (start == string::npos)
+		return "";
+	else
+		return aString.substr(start, 1+aString.find_last_not_of(WhiteSpace)-start);
+	}
+
+
+THtmlParseLayoutTable::THtmlParseLayoutTable(TLayout* aTables) 
+: TLayoutTable(aTables)
+	{
+	}
+
+THtmlParseLayoutTable::~THtmlParseLayoutTable()
+	{
+	}
+
+bool THtmlParseLayoutTable::Read(istream& in)
+	{
+	iIn = &in;
+
+	if (!SearchForTableStart())
+		return false;
+
+	ExtractTable();
+
+	iIn = 0;
+
+	return true;
+	}
+
+bool THtmlParseLayoutTable::SearchForTableStart()
+	{
+	string text;
+	while (!Eof())
+		{
+		string next = Next();
+		if (IsToken(next))
+			{
+			if (next.substr(0,6) == "<TABLE")
+				{
+				ExtractTitle(text);
+				return true;
+				}
+			}
+		else
+			{
+			if (next.substr(0,5) == "Table")
+				text = next.substr(5);
+			else
+				text += next;
+			}
+		}
+
+	return false;
+	}
+
+set<string> gKnownTitles;
+
+void THtmlParseLayoutTable::ExtractTitle(const string& aText)
+	{
+	iName = UnHtml(aText);
+	int pos = iName.find_first_not_of("1234567890.\t\r\n ");
+	if (pos == string::npos)
+		return;
+	iName = iName.substr(pos);
+	iName = StripTo(iName, gValidText);
+	iName = TrimWhiteSpace(iName);
+
+	while (gKnownTitles.find(iName) != gKnownTitles.end())
+		iName += "_dup";
+
+	gKnownTitles.insert(iName);
+	}
+
+void THtmlParseLayoutTable::ExtractTable()
+	{
+	string cell;
+	string td;
+	Row row;
+	while (!Eof())
+		{
+		string tok = Next();
+		if (IsToken(tok))
+			{
+			if (tok.substr(0,4) == "<TD ")
+				{
+				td = tok;
+				}
+			else if (tok == "</TD>")
+				{
+				row.push_back(CleanCell(cell, row));
+				cell = "";
+				int colspan = GetVal(td, "COLSPAN");
+				for (int i=1; i<colspan; i++)
+					row.push_back("");
+				}
+			else if (tok == "</TR>")
+				{
+				if (!row[1].length())
+					row[1] = "untitled";
+				AddRow(row);
+				row.erase(row.begin(), row.end());
+				}
+			else if (tok == "</TABLE>")
+				{
+				break;
+				}
+			else if (cell.length() && (tok == "<BR>" || tok == "<P>"))
+				{
+				cell += ", ";
+				}
+			}
+		else
+			{
+			cell += tok;
+			}
+		}
+	}
+
+string THtmlParseLayoutTable::CleanCell(const string& cell, const Row& row)
+	{
+	if (iColumnNames.size() < 6)		// table header
+		return cell;
+	else if (row.size() < 2 || row.size() == iColumnNames.size())	// free text
+		return StripTo(UnHtml(cell),gValidText+KEllipsis);
+	else
+		return CleanMultiCell(StripTo(UnHtml(cell),gValidText+"/,*"));	// value cell
+	}
+
+string THtmlParseLayoutTable::Next()
+	{
+	string s;
+	char c;
+
+	do	{
+		c = Get(); 
+		} while (!Eof() && WhiteSpace.find(c) != string::npos);
+	s += c;
+
+	if (c == '<')
+		{
+		do	{
+			c = Get(); 
+			s += toupper(c);
+			} while (!Eof() && c != '>');
+		}
+	else
+		{
+		do	{
+			c = Get(); 
+			s += c;
+			} while (!Eof() && c != '<');
+
+		if (c == '<')
+			PutBack(c);
+
+		s = s.substr(0, s.find_last_not_of(WhiteSpace));
+		}
+
+	return s;
+	}
+
+bool THtmlParseLayoutTable::IsToken(const string& aText)
+	{
+	return aText.length()>0 && aText[0] == '<';
+	}
+
+void THtmlParseLayoutTable::PutBack(const string& aText)
+	{
+	for (string::const_reverse_iterator pC = aText.rbegin(); pC != aText.rend(); ++pC)
+		PutBack(*pC);
+	}
+
+int THtmlParseLayoutTable::GetVal(const string& aText, const string& aField)
+	{
+	int pos = aText.find(aField+"=");
+	if (pos == string::npos)
+		return 0;
+	string val = aText.substr(pos + aField.length() + 1);
+	val = val.substr(0, val.find_first_of(WhiteSpace + ">"));
+	stringstream s(val);
+	int ret;
+	s >> ret;
+	return ret;
+	}
+
+char THtmlParseLayoutTable::Get()
+	{
+	if (iPutBack.length())
+		{
+		char c = iPutBack[iPutBack.length()-1];
+		iPutBack.erase(iPutBack.length()-1, 1);
+		return c;
+		}
+	else
+		{
+		return iIn->get();
+		}
+	}
+
+void THtmlParseLayoutTable::PutBack(char aChar)
+	{
+	iPutBack += aChar;
+	}
+
+bool THtmlParseLayoutTable::Eof()
+	{
+	return iPutBack.length()==0 && iIn->eof();
+	}
+
+string THtmlParseLayoutTable::CleanMultiCell(const string& aText)
+	{
+	// This function removes trailing commas from the end of cells where there is no
+	// comma in the middle of the cell. 
+	// needed because of odd formatting found.
+	if (aText.length()==0)
+		return aText;
+
+	int pos = aText.find_last_not_of(" ,");
+	if (pos == string::npos)
+		return "";
+
+	string text;
+	if (aText.substr(0,pos+1).find(",") == string::npos)
+		text = aText.substr(0,pos+1);
+	else
+		text = aText;
+
+	return text;
+	}
+
+const int KMaxStars = 16;
+struct SCellParamDesc
+	{
+	SCellParamDesc();
+	bool operator==(const SCellParamDesc& a);
+	int iParams;
+	bool iStars[KMaxStars];
+	};
+
+SCellParamDesc::SCellParamDesc() 
+	{ 
+	iParams=0;
+	for (int i=0; i<KMaxStars; i++)
+		iStars[i] = false; 
+	}
+
+bool SCellParamDesc::operator==(const SCellParamDesc& a) 
+	{
+	if (iParams!=a.iParams)
+		return false;
+
+	for (int i=0; i<KMaxStars; i++)
+		{
+		if (iStars[i]!=a.iStars[i])
+			return false;
+		}
+
+	return true;
+	}
+
+THtmlParseLayoutTable::Row THtmlParseLayoutTable::MakeParamTable(const Row& row, int start, int num)
+	{
+	Row params;
+	vector<SCellParamDesc> paramDescs;
+
+	// initialise params
+	for (Row::const_iterator pR = row.begin(); pR != row.end(); ++pR)
+		{
+		params.push_back("");
+		paramDescs.push_back(SCellParamDesc());
+		}
+
+	// count params and stars
+	int i;
+	for (i=0; i<num; i++)
+		{
+		SCellParamDesc& desc = paramDescs[start+i];
+		const string& cell = row[start+i];
+		desc.iParams = 1;
+
+		int starCount=0;
+		for (string::const_iterator pC = cell.begin(); pC != cell.end(); ++pC)
+			{
+			if (*pC == '*')
+				{
+				starCount++;
+				}
+			else
+				{
+				if (starCount)
+					{
+					desc.iStars[starCount-1] = true;
+					starCount = 0;
+					}
+				if (*pC == ',')
+					{
+					desc.iParams++;
+					}
+				}
+			}
+
+		if (starCount)
+			desc.iStars[starCount-1] = true;
+		}
+
+	// assign parameter names
+	string name("aCommon1");
+	for (i=0; i<num; i++)
+		{
+		SCellParamDesc& desc = paramDescs[start+i];
+		if (desc.iParams == 1)
+			continue;
+
+		string& param = params[start+i];
+
+		int count = 0;
+		bool first = true;
+
+		// look for a similar cell
+		for (int j=0; j<num; j++)
+			{
+			if (paramDescs[start+j] == desc)
+				{
+				count++;
+				if (count == 1 && j<i)
+					{
+					first = false;
+					param = params[start+j];
+					}
+				}
+			}
+
+		// assign a new name if there is no similar cell already named
+		if (count>1 && first)
+			{
+			param = name;
+			name[7]++;
+			}
+		}
+
+	return params;
+	}
+
+void THtmlParseLayoutTable::AddRow(Row& row)
+	{
+	if (row.size()==0)
+		return;				// empty row
+
+	const string& first = row[0];
+
+	if (first.length()==0 || first == "P")
+		AddTitleRow(row);
+	else if (first == "No.")
+		AddColumnNameRow(row);
+	else if (first == KEllipsis)
+		iAppend = true;
+	else
+		AddLineRow(row);
+	}
+
+void THtmlParseLayoutTable::AddColumnNameRow(Row& row)
+	{
+	if (row.size()<4)
+		return;				// unknown row type
+
+	if (row[1] == "Value")
+		row[1] = "Item";
+
+	if (row[1] == "Font")
+		iType = ETextTable;
+	else if (row[1] == "Item")
+		iType = EWindowTable;
+	else
+		return;				// unknown row type
+
+	SetDefaultColumnNames();
+	iColumnNames.insert(iColumnNames.begin()+3, "b/r"); // for skins LAF
+
+	int foundCount = 0;
+	vector<string> foundColNames;
+	for (Row::iterator pCol = row.begin()+1; pCol != row.end(); pCol++)
+		{
+		string cellTitle = *pCol;
+		if (cellTitle == "Remarks.")
+			cellTitle = "Remarks";
+		if (iType == ETextTable && cellTitle == "Margins")
+			{
+			foundColNames.push_back("l");
+			foundColNames.push_back("r");
+			pCol++;
+			}
+		else if (find(iColumnNames.begin(),iColumnNames.end(),cellTitle) != iColumnNames.end())
+			{
+			foundColNames.push_back(cellTitle);
+			foundCount++;
+			}
+		else
+			{
+			foundColNames.push_back(KUnknown);
+			}
+		}
+	iColumnNames = foundColNames;
+
+	if (foundCount < 4)
+		{
+		iColumnNames.clear();
+		iType = EUnknownTable;
+		}
+	}
+
+void THtmlParseLayoutTable::AddLineRow(const Row& row)
+	{
+	if (iColumnNames.size() == 0 || row.size() != iColumnNames.size()+1)
+		return;		// unknown row type;
+
+	Row params = MakeParamTable(row, 2, iColumnNames.size()-2);
+
+	Row::const_iterator pCell = row.begin();
+	Row::const_iterator pParam = params.begin();
+
+	int id;
+	stringstream stream(*pCell);
+	stream >> id;
+	if (id == 0)
+		return;		// bad id;
+
+	TLayoutLine* line = new TLayoutLine(this, id);
+	push_back(line);
+
+	bool found_l = false;
+	for (vector<string>::iterator pCol = iColumnNames.begin(); pCol != iColumnNames.end(); ++pCol)
+		{
+		string col = *pCol;
+		if (col == "b/r")
+			col = found_l ? "b" : "r";
+
+		++pCell;
+		++pParam;
+		TValues values(line, col);
+
+		if (pParam->size())
+			values.iParam = *pParam;
+
+		string cell = *pCell;
+		if (IsValueColumn(col))
+			cell = ConvertToAknName(SplitMultiCell(cell, IsNumericColumn(col) ? gValidNum : gValidText));
+
+		int pos=0;
+		do	{
+			int newPos = cell.find(',', pos);
+			values.push_back(TrimWhiteSpace(cell.substr(pos, newPos-pos)));
+			pos = newPos+1;
+			} while (pos);
+
+		if ((values.size()>1 || values[0].size()>0) && col == "l")
+			found_l = true;
+
+		if (col != KUnknown)
+			line->insert(make_pair(col, values));
+		}
+	}
+
+void THtmlParseLayoutTable::AddTitleRow(const Row& row)
+	{
+	if (row.size() < 2)
+		return;
+	if (row[0] == "P")
+		iParentName = TrimWhiteSpace(row[1]);
+	}
+
+string THtmlParseLayoutTable::SplitMultiCell(const string& aCell, const string& aValid)
+	{
+	string cell = aCell;
+
+	// Make sure commas are in correctly!
+	cell = StripTo(UnHtml(cell), aValid+"/,");
+	
+	int lastComma = -1;
+	int lastSpace = -1;
+	int lastNum = -1;
+	
+	for (int i=0; i<cell.length(); i++)
+		{
+		char c = cell[i];
+		if (c == ',')
+			lastComma = i;
+		else if (c == ' ' || c == '/')
+			lastSpace = i;
+		else 
+			{
+			if (lastSpace > lastNum && lastNum > lastComma)
+				{
+				cell[lastSpace] = ',';
+				lastComma = lastSpace;
+				}
+			lastNum = i;
+			}
+		}
+
+	cell = StripTo(UnHtml(cell), aValid+",");
+	if (cell == "-")
+		cell = "";
+
+	return cell;
+	}
+
+string THtmlParseLayoutTable::StripTo(const string& aText, const string& aValid)
+	{
+	string cell("");
+	for (string::const_iterator pC = aText.begin(); pC != aText.end(); ++pC)
+		{
+		if (aValid.find(*pC) != string::npos)
+			cell += *pC;
+		}
+	return cell;
+	}
+
+string THtmlParseLayoutTable::UnHtml(const string& aText)
+	{
+	string str("");
+	for (int i=0; i<aText.size(); i++)
+		{
+		char c = aText[i];
+		if (c == '&')
+			{
+			string s = aText.substr(i);
+			int pos = s.find(";");
+			if (pos != string::npos)
+				{
+				i+=pos;
+				c = HtmlChar(s.substr(1, pos-1));
+				}
+			}
+		else if (c == char(0x96))
+			{
+			c = '-';
+			}
+		str += c;
+		}
+	return str;
+	}
+
+struct THtmlChar {char* iString; char iChar;};
+const THtmlChar gHtmlChars[] =
+	{
+		{"gt", '>'},
+		{"lt", '<'},
+		{"nbsp", ' '},
+		{"#9", '\t'}
+	};
+
+char THtmlParseLayoutTable::HtmlChar(const string& aText)
+	{
+	for (int i=0; i<sizeof(gHtmlChars)/sizeof(THtmlChar); i++)
+		{
+		if (aText == gHtmlChars[i].iString)
+			return gHtmlChars[i].iChar;
+		}
+	return '_';
+	}
+
+struct SConvertAknName
+	{
+	char* iLaf;
+	char* iAkn;
+	};
+
+SConvertAknName gAknNameConversionTable[] =
+	{
+		{ "left", "ELayoutAlignLeft" },
+		{ "right", "ELayoutAlignRight" },
+		{ "centre", "ELayoutAlignCenter" },
+		{ "center", "ELayoutAlignCenter" },
+		{ "bidi", "ELayoutAlignBidi" },
+		{ "qfn_latin_bold_19", "ELatinBold19" },
+		{ "qfn_latin_bold_17", "ELatinBold17" },
+		{ "qfn_latin_bold_13", "ELatinBold13" },
+		{ "qfn_latin_bold_12", "ELatinBold12" },
+		{ "qfn_latin_plain_12", "ELatinPlain12" },
+		{ "qfn_latin_plain_13", "ELatinPlain12" },			// made up for elaf spec, only needed by navi pane?
+		{ "qfn_latin_clock_14", "ELatinClock14" },
+		{ "qfn_<ref>_plain_12", "EApacPlain12" },	
+		{ "qfn_<ref>_plain_16", "EApacPlain16" },
+		{ "qfn_china_plain_12", "EApacPlain12" },
+		{ "qfn_number_plain_5", "ENumberPlain5" },
+		{ "qfn_china_plain_16", "EApacPlain16" },
+		{ "qfn_clock_bold_30", "EClockBold30" },	
+		{ "qfn_number_bold_14", "ELatinClock14" },
+		{ "gfn_<ref>_plain_12", "EApacPlain12" },
+		{ "gfn_<ref>_plain_16", "EApacPlain16" },
+		{ "gfn_latin_bold_16", "ELatinBold16" },
+		{ "qfn_calc_21", "ECalcBold21" },
+		{ "qfn_calc_oper_21", "ECalcOperBold21" },
+		{ "qfn_calc_oper_13", "ECalcOperBold13" }
+	};
+
+string THtmlParseLayoutTable::ConvertToAknName(const string& aText)
+	{
+	string ret = aText;
+	for (int i=0; i<sizeof(gAknNameConversionTable)/sizeof(SConvertAknName); i++)
+		{
+		string laf = gAknNameConversionTable[i].iLaf;
+		string akn = gAknNameConversionTable[i].iAkn;
+		int pos;
+		while ((pos = ret.find(laf)) != string::npos)
+			{
+			ret.erase(pos, laf.length());
+			ret.insert(pos, akn);
+			}
+		}
+	return ret;
+	}
+
+
+void THtmlParseLayout::Parse(istream &aIn)
+	{
+	while (!aIn.eof())
+		{
+		auto_ptr<THtmlParseLayoutTable> table(new THtmlParseLayoutTable(this));
+		if (table->Read(aIn))
+			{
+			if (table->size() > 0)
+				push_back(table.release());
+			}
+		else
+			break;
+		}
+	Compile();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Lay2Cdl.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,263 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       Defines the entry point for the console application
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "Lay2Cdl.h"
+#include "LayoutParse.h"
+#include "LayoutCompilerErr.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+#include "CppWriter.h"
+#include "CodeGenConsts.h"
+
+using namespace std;
+
+typedef LayoutProcessArgsErr<LayoutToCdl> LayoutToCdlArgsErr;
+
+const int KGeneratedInterfaceMajorVer = 1;
+const int KGeneratedInterfaceMinorVer = 0;
+
+string LayoutToCdl::InterfaceName(const string& aFileName)
+	{
+	return aFileName.substr(0,aFileName.find_last_of('.'));
+	}
+
+int LayoutToCdl::Process(const vector<string>& args)
+	{
+	if (args.size() != 5)
+		throw LayoutToCdlArgsErr();
+
+	string layoutName = args[2];
+	auto_ptr<TLayParseLayout> layout(TLayParseLayout::Parse(layoutName));
+
+	string cdlName = args[3];
+	int uid = CdlTkUtil::ParseInt(args[4]);
+	auto_ptr<CCdlTkInterface> iface(LayoutToInterface(*layout));
+
+	SetHeaders(*iface, cdlName, uid);
+
+	CCdlTkWriteCdlFile writer(*iface);
+	cout << "writing CDL file " << cdlName << endl;
+	writer.Process();
+	return 0;
+	}
+
+void LayoutToCdl::ShowHelp(ostream& stream)
+	{
+	stream << "Lay2Cdl <layoutName> <cdlName> <UID>" << endl;
+	}
+
+auto_ptr<CCdlTkInterface> LayoutToCdl::LayoutToInterface(const TLayout& aLayout)
+	{
+	auto_ptr<CCdlTkInterface> iface(new CCdlTkInterface);
+
+	for (TLayout::const_iterator pTab = aLayout.begin(); pTab != aLayout.end(); ++pTab)
+		{
+		AddTableToInterface(*iface, **pTab);
+		}
+
+	return iface;
+	}
+
+void LayoutToCdl::AddTableToInterface(CCdlTkInterface& aInterface, TLayoutTable& aTable)
+	{
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		if (aTable.iType == TLayoutTable::EWindowTable)
+			AddWindowLineToInterface(aInterface, **pLine);
+		else
+			AddTextLineToInterface(aInterface, **pLine);
+
+		if (pLine == aTable.begin())
+			{
+			CCdlTkApi& api = **aInterface.ApiList().rbegin();
+			api.SetComment(string("// LAF Table : ") + aTable.Name() + "\n");
+			}
+		}
+
+	int tableNum = 0;
+	for (TLayoutTable::TLayoutSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+		{
+		AddTableLimitsToInterface(aInterface, aTable, **pSub, tableNum);
+		string tableType = KTypeTextLineLayout;
+		if (aTable.iType == TLayoutTable::EWindowTable)
+			tableType == KTypeWindowLineLayout;
+		AddSubTableToInterface(tableType, aInterface, aTable, **pSub, tableNum);
+		tableNum++;
+		}
+	}
+
+void LayoutToCdl::AddWindowLineToInterface(CCdlTkInterface& aInterface, TLayoutLine& aLine)
+	{
+	CCdlTkApi* api = CreateGenericApi(aInterface, aLine);
+
+	api->SetName(LineApiName(aLine));
+	api->SetReturnType(KTypeWindowLineLayout);
+
+	aInterface.ApiList().push_back(api);
+	}
+
+void LayoutToCdl::AddTextLineToInterface(CCdlTkInterface& aInterface, TLayoutLine& aLine)
+	{
+	CCdlTkApi* api = CreateGenericApi(aInterface, aLine);
+
+	api->SetName(LineApiName(aLine));
+	api->SetReturnType(KTypeTextLineLayout);
+
+	aInterface.ApiList().push_back(api);
+
+	TValues& v = aLine["B"];
+	if (v.size()>1)
+		{
+		CCdlTkFunctionApi* multiline = static_cast<CCdlTkFunctionApi*>(CreateGenericApi(aInterface, aLine));
+		CCdlTkApiParams& params = multiline->Params();
+		CCdlTkApiParams::iterator pParam = params.FindByName(KParamNameB);
+		if (pParam != params.end())
+			params.erase(pParam);
+		params.push_back(CCdlTkApiParam(KTypeInt, KParamNameNumberOfLinesShown));
+
+		multiline->SetName(KFuncMultiline + LineApiName(aLine));
+		multiline->SetReturnType(KTypeMultiLineTextLayout);
+
+		aInterface.ApiList().push_back(multiline);
+		}
+	}
+
+string LayoutToCdl::TableApiName(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	if (aTable.size() == aSubTable.size())
+		return CdlTkUtil::ToCpp(aTable.Name());
+	else
+		return CdlTkUtil::ToCpp(aTable.Name()) + "_SUB_TABLE_" + CdlTkUtil::IntToString(aSubTableNum);
+	}
+
+string LayoutToCdl::LineApiName(TLayoutLine& aLine)
+	{
+	if (aLine.iTable->iType == TLayoutTable::EWindowTable)
+		{
+		TWindowLineCppWriter writer(aLine);
+		return writer.Name();
+		}
+	else
+		{
+		TTextLineCppWriter writer(aLine);
+		return writer.Name();
+		}
+	}
+
+void LayoutToCdl::AddSubTableToInterface(const string& aType, CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	TLayoutLine& line = *aTable[aSubTable[0]];
+	CCdlTkFunctionApi* api = new CCdlTkFunctionApi(aInterface);
+	api->Params().push_back(CCdlTkApiParam(KTypeInt, KParamLineIndex));
+	AddParamsToFunc(line, *api);
+
+	api->SetReturnType(aType);
+
+	api->SetName(TableApiName(aTable, aSubTable, aSubTableNum));
+
+	aInterface.ApiList().push_back(api);
+	}
+
+void LayoutToCdl::AddTableLimitsToInterface(CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	CCdlTkFunctionApi* api = new CCdlTkFunctionApi(aInterface);
+	api->SetReturnType(KTypeLayoutTableLimits);
+	api->SetName(TableApiName(aTable, aSubTable, aSubTableNum)+KFuncLimitsSuffix);
+	aInterface.ApiList().push_back(api);
+	}
+
+CCdlTkApi* LayoutToCdl::CreateGenericApi(CCdlTkInterface& aInterface, TLayoutLine& aLine)
+	{
+	CCdlTkFunctionApi* func = new CCdlTkFunctionApi(aInterface);
+	AddParamsToFunc(aLine, *func);
+	return func;
+	}
+
+void LayoutToCdl::AddParamsToFunc(TLayoutLine& aLine, CCdlTkFunctionApi& aFunc)
+	{
+	CCdlTkApiParams& params = aFunc.Params();
+
+	bool mirrored = aLine.iIsMirroredHorizontally;
+
+	if (aLine.iNeedsP)
+		params.push_back(CCdlTkApiParam(KTypeRect, KParamParentRect));
+
+	if (aLine.iNeedsIndex)
+		{
+		const string* KParams;
+		int count;
+		if (aLine.iTable->iType == TLayoutTable::EWindowTable)
+			{
+			if (mirrored)
+				KParams = KWindowOutputOrderMirrored;
+			else
+				KParams = KWindowOutputOrder;
+			count = KWindowOutputOrderSize;
+			}
+		else
+			{
+			if (mirrored)
+				KParams = KTextOutputOrderMirrored;
+			else
+				KParams = KTextOutputOrder;
+			count = KTextOutputOrderSize;
+			}
+
+		for (int i=0; i<count; i++)
+			{
+			const string& name = KParams[i];
+
+			const TValues& defValues = aLine[name];
+			if (defValues.iNeedsIndex)
+				{
+				string paramName = CdlTkUtil::ToCpp(defValues.ParamName());
+				if (mirrored)
+					{
+					if (paramName == KParamNameL)
+						paramName = KParamNameR;
+					else if (paramName == KParamNameR)
+						paramName = KParamNameL;
+					}
+
+				CCdlTkApiParam param(KTypeInt, paramName);
+				if (params.FindByName(param.Name()) == params.end())
+					params.push_back(param);
+				}
+			}
+		}
+	}
+
+void LayoutToCdl::SetHeaders(CCdlTkInterface& aInterface, const string& aCdlName, int aUid)
+	{
+	aInterface.SetFileName(aCdlName);
+	aInterface.Header().SetUid(aUid);
+	aInterface.Header().Flags().SetFlag("KCdlFlagRomOnly");
+
+	string ifName(InterfaceName(CdlTkUtil::StripPath(aCdlName)));
+	aInterface.Header().SetName(ifName);
+	aInterface.Header().SetVersion(CCdlTkInterfaceHeader::CVersion(KGeneratedInterfaceMajorVer, KGeneratedInterfaceMinorVer));
+	aInterface.Cpp().push_back("#include <aknlayout2def.h>");
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Lay2LayPerf.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "Lay2LayPerf.h"
+#include "LayoutParse.h"
+#include "LayoutCompilerErr.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+#include "LayPerfWriter.h"
+
+typedef LayoutProcessArgsErr<LayoutToLayPerf> LayoutToLayPerfArgsErr;
+
+
+string LayoutToLayPerf::InterfaceName(const string& aFileName)
+	{
+	return aFileName.substr(0,aFileName.find_last_of('.'));
+	}
+
+int LayoutToLayPerf::Process(const vector<string>& args)
+	{
+	if (args.size() != 5)
+		throw LayoutToLayPerfArgsErr();
+
+	string cdlName = args[2];
+
+	auto_ptr<TLayParseLayout> sourceLayout(TLayParseLayout::Parse(args[3]));
+	string destLayout = args[4];
+
+	LayoutToLayPerf layPerf(cdlName, *sourceLayout, destLayout);
+	layPerf.WriteLayout();
+
+	return 0;
+	}
+
+void LayoutToLayPerf::ShowHelp(ostream& stream)
+	{
+	stream << "Lay2LayPerf <layout.cdl> <source.lay> <layPerf.cpp> " << endl;
+	stream << "Lay2LayPerf ..\\cdl\\AknLayout.cdl ..\\layout\\AknElaf.lay \\s60\\akntest\\layperf\\generated\\LayPerf_AknElaf.cpp " << endl;
+	stream << "  This converts a LAY file into a specialised format for inclusion in the LayPerf test app." << endl;
+	stream << "  LayPerf runs on the device, calling each API that would be generated from the LAY file." << endl;
+	}
+
+
+
+LayoutToLayPerf::LayoutToLayPerf(const string& aCdlName, TLayout& aSourceLayout, const string& aDestLayoutName)
+:	
+	iCdlName(aCdlName),
+	iLayout(aSourceLayout),
+	iDestLayoutName(aDestLayoutName)
+	{
+	}
+
+void LayoutToLayPerf::WriteLayout()
+	{
+	TLayPerfWriter writer(iLayout, iDestLayoutName);
+	writer.Write(iCdlName);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Lay2MLInst.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,329 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "lay2MLInst.h"
+#include "LayoutParse.h"
+#include "LayoutCompilerErr.h"
+
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+#include "MLInstWriter.h"
+//#include "MLInstParse.h"
+
+string TextOutputOrder(int aIndex, bool aMirrored);
+string WindowOutputOrder(int aIndex, bool aMirrored);
+
+using namespace std;
+
+class LayoutToMLInstArgsErr : public LayoutCompilerErr
+	{
+	void Show(ostream& aStream) const;
+	};
+
+void LayoutToMLInstArgsErr::Show(ostream& stream) const
+	{
+	LayoutToMLInst::ShowHelp(stream);
+	}
+
+string LayoutToMLInst::InterfaceName(const string& aFileName)
+	{
+	return aFileName.substr(0,aFileName.find_last_of('.'));
+	}
+
+int LayoutToMLInst::Process(const vector<string>& args)
+	{
+	if (args.size() != 4)
+		throw LayoutToMLInstArgsErr();
+
+	// first read in the lay file
+	string layoutName = args[2];
+	auto_ptr<TLayParseLayout> layoutParse(TLayParseLayout::Parse(layoutName));
+
+	// then convert it to internal structure format
+	auto_ptr<TMLInst> mlInst(LayoutToInst(*layoutParse));
+
+	// finally write out the structure XML
+	string xmlName = args[3];
+	cout << "writing XML file " << xmlName << endl;
+	TMLInstWriter writer(*mlInst, xmlName);
+	writer.Write(layoutName);
+	return 0;
+	}
+
+void LayoutToMLInst::ShowHelp(ostream& stream)
+	{
+	stream << "Lay2MLInst <layoutName> <instXmlName>" << endl;
+	}
+
+auto_ptr<TMLInst> LayoutToMLInst::LayoutToInst(const TLayout& aLayout)
+	{
+	auto_ptr<TMLInst> mlInst(new TMLInst);
+
+	for (TLayout::const_iterator pTab = aLayout.begin(); pTab != aLayout.end(); ++pTab)
+		{
+		AddTableToInst(*mlInst, **pTab);
+		}
+	
+	return mlInst;
+	}
+
+void LayoutToMLInst::AddTableToInst(TMLInst& aInst, TLayoutTable& aTable)
+	{
+	TMLInstTable* instTable = new TMLInstTable(&aInst, aTable);
+
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		if (aTable.iType == TLayoutTable::EWindowTable)
+			AddWindowLineToInstTable(*instTable, **pLine);
+		else
+			AddTextLineToInstTable(*instTable, **pLine);
+		}
+
+/*
+	int tableNum = 0;
+	for (TLayoutTable::TLayoutSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+		{
+		AddTableLimitsToInterface(aInterface, aTable, **pSub, tableNum);
+		if (aTable.iType == TLayoutTable::EWindowTable)
+			AddSubTableToInterface("TAknWindowLineLayout", aInterface, aTable, **pSub, tableNum);
+		else
+			AddSubTableToInterface("TAknTextLineLayout", aInterface, aTable, **pSub, tableNum);
+		tableNum++;
+		}
+*/
+	aInst.push_back(instTable);
+	}
+
+void LayoutToMLInst::AddWindowLineToInstTable(TMLInstTable& aInstTable, TLayoutLine& aLine)
+	{
+	TMLInstLine* instLine = new TMLInstLine(&aInstTable, aLine);
+/*
+	CCdlTkApi* api = CreateGenericApi(aInterface, aLine);
+	api->SetName(LineApiName(aLine));
+	api->SetReturnType("TAknWindowLineLayout");
+	aInterface.ApiList().push_back(api);
+*/
+
+
+	// add a value for each top level cell
+	for (int i=0; i<7; i++)
+		{
+		string cellName = WindowOutputOrder(i, false);
+//		WriteCell(line, cellName, aLine[cellName]);
+		AddParamToLine(*instLine, aLine[cellName]);
+		}
+
+/*
+	for(TLayoutLine::iterator pValue = aLine.begin(); pValue != aLine.end(); ++pValue)
+		{
+		AddParamToLine(instLine, *pValue);
+		}
+*/
+	aInstTable.push_back(instLine);
+	}
+
+void LayoutToMLInst::AddTextLineToInstTable(TMLInstTable& aInstTable, TLayoutLine& aLine)
+	{
+	TMLInstLine* instLine = new TMLInstLine(&aInstTable, aLine);
+
+/*
+	CCdlTkApi* api = CreateGenericApi(aInterface, aLine);
+
+	api->SetName(LineApiName(aLine));
+	api->SetReturnType("TAknTextLineLayout");
+
+	aInterface.ApiList().push_back(api);
+*/
+
+	for (int i=0; i<6; i++)
+		{
+		string cellName = TextOutputOrder(i, false);
+//		WriteCell(line, cellName, aLine[cellName]);
+		AddParamToLine(*instLine, aLine[cellName]);
+		}
+
+/*
+	for(TLayoutLine::iterator pValue = aLine.begin(); pValue != aLine.end(); ++pValue)
+		{
+		AddParamToLine(instLine, *pValue);
+		}
+*/
+	aInstTable.push_back(instLine);
+
+
+/*
+	TValues& v = aLine["B"];
+	if (v.size()>1)
+		{
+		CCdlTkFunctionApi* multiline = static_cast<CCdlTkFunctionApi*>(CreateGenericApi(aInterface, aLine));
+		CCdlTkApiParams& params = multiline->Params();
+		CCdlTkApiParams::iterator pParam = params.FindByName("aIndex_B");
+		if (pParam != params.end())
+			params.erase(pParam);
+		params.push_back(CCdlTkApiParam("TInt", "aNumberOfLinesShown"));
+
+		multiline->SetName(string("Multiline_") + LineApiName(aLine));
+		multiline->SetReturnType("TAknMultiLineTextLayout");
+
+		aInterface.ApiList().push_back(multiline);
+		}
+*/
+	}
+
+/*
+string LayoutToMLInst::TableApiName(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	if (aTable.size() == aSubTable.size())
+		return CdlTkUtil::ToCpp(aTable.Name());
+	else
+		return CdlTkUtil::ToCpp(aTable.Name()) + "_SUB_TABLE_" + IntToString(aSubTableNum);
+	}
+
+string LayoutToMLInst::LineApiName(TLayoutLine& aLine)
+	{
+	if (aLine.iTable->iType == TLayoutTable::EWindowTable)
+		{
+		TWindowLineCppWriter writer(aLine);
+		return writer.Name();
+		}
+	else
+		{
+		TTextLineCppWriter writer(aLine);
+		return writer.Name();
+		}
+	}
+
+void LayoutToMLInst::AddSubTableToInterface(const string& aType, CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	TLayoutLine& line = *aTable[aSubTable[0]];
+	CCdlTkFunctionApi* api = new CCdlTkFunctionApi(aInterface);
+	api->Params().push_back(CCdlTkApiParam("TInt", "aLineIndex"));
+	AddParamsToFunc(line, *api);
+
+	api->SetReturnType(aType);
+
+	api->SetName(TableApiName(aTable, aSubTable, aSubTableNum));
+
+	aInterface.ApiList().push_back(api);
+	}
+
+void LayoutToMLInst::AddTableLimitsToInterface(CCdlTkInterface& aInterface, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aSubTableNum)
+	{
+	CCdlTkFunctionApi* api = new CCdlTkFunctionApi(aInterface);
+	api->SetReturnType("TAknLayoutTableLimits");
+	api->SetName(TableApiName(aTable, aSubTable, aSubTableNum)+"_Limits");
+	aInterface.ApiList().push_back(api);
+	}
+
+CCdlTkApi* LayoutToMLInst::CreateGenericApi(CCdlTkInterface& aInterface, TLayoutLine& aLine)
+	{
+	CCdlTkFunctionApi* func = new CCdlTkFunctionApi(aInterface);
+	AddParamsToFunc(aLine, *func);
+	return func;
+	}
+
+void LayoutToMLInst::AddParamsToFunc(TLayoutLine& aLine, CCdlTkFunctionApi& aFunc)
+	{
+	CCdlTkApiParams& params = aFunc.Params();
+
+	if (aLine.iNeedsP)
+		params.push_back(CCdlTkApiParam("const TRect&", "aParentRect"));
+
+	if (aLine.iNeedsIndex)
+		{
+		const string* KParams;
+		int count;
+		if (aLine.iTable->iType == TLayoutTable::EWindowTable)
+			{
+			KParams = KWindowOutputOrder;
+			count = KWindowOutputOrderSize;
+			}
+		else
+			{
+			KParams = KTextOutputOrder;
+			count = KTextOutputOrderSize;
+			}
+
+		for (int i=0; i<count; i++)
+			{
+			const string& name = KParams[i];
+
+			const TValues& defValues = aLine[name];
+			if (defValues.iNeedsIndex)
+				{
+				CCdlTkApiParam param("TInt", CdlTkUtil::ToCpp(defValues.ParamName()));
+				if (params.FindByName(param.Name()) == params.end())
+					params.push_back(param);
+				}
+			}
+		}
+	}
+
+*/
+
+void LayoutToMLInst::AddParamToLine(TMLInstLine& aInstLine, TValues& aValue)
+	{
+//	CCdlTkApiParams& params = aFunc.Params();
+
+	TMLInstParam* instLine = new TMLInstParam(&aInstLine, aValue);
+
+	for(TValues::iterator pInt = aValue.begin(); pInt != aValue.end(); ++pInt)
+		{
+		instLine->iValues.push_back(*pInt);
+		}
+
+/*
+	if (aLine.iNeedsP)
+		params.push_back(CCdlTkApiParam("const TRect&", "aParentRect"));
+
+	if (aLine.iNeedsIndex)
+		{
+		const string* KParams;
+		int count;
+		if (aLine.iTable->iType == TLayoutTable::EWindowTable)
+			{
+			KParams = KWindowOutputOrder;
+			count = KWindowOutputOrderSize;
+			}
+		else
+			{
+			KParams = KTextOutputOrder;
+			count = KTextOutputOrderSize;
+			}
+
+		for (int i=0; i<count; i++)
+			{
+			const string& name = KParams[i];
+
+			const TValues& defValues = aLine[name];
+			if (defValues.iNeedsIndex)
+				{
+				CCdlTkApiParam param("TInt", CdlTkUtil::ToCpp(defValues.ParamName()));
+				if (params.FindByName(param.Name()) == params.end())
+					params.push_back(param);
+				}
+			}
+		}
+*/
+
+	aInstLine.push_back(instLine);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayCdl2Inst.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,583 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayCdl2Inst.h"
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "CppWriter.h"
+#include "Lay2Cdl.h"
+#include <fstream>
+#include <algorithm>
+#include <iostream>
+#include "CodeGenConsts.h"
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<LayoutAndCdlToCdlInstance> LayoutAndCdlToCdlInstanceArgsErr;
+
+
+class LayoutAndCdlToCdlInstanceChecker : public MCdlTkApiCheckObserver
+	{
+private:
+	void StartCheck();
+	void CheckComplete();
+	void ApiInBoth(const CCdlTkApi& aApi);
+	void ApiNotInLeft(const CCdlTkApi& aApi);
+	void ApiNotInRight(const CCdlTkApi& aApi);
+
+private:
+	int iNotInLeft;
+	int iNotInRight;
+	};
+
+
+void LayoutAndCdlToCdlInstanceChecker::StartCheck()
+	{
+	iNotInLeft = 0;
+	iNotInRight = 0;
+	}
+
+void LayoutAndCdlToCdlInstanceChecker::CheckComplete()
+	{
+	if (iNotInLeft)
+		cout << "Layout is partial implementation of interface" << endl;
+	if (iNotInRight)
+		throw CdlTkAssert("Layout interface check failed");
+	}
+
+void LayoutAndCdlToCdlInstanceChecker::ApiInBoth(const CCdlTkApi& /*aApi*/)
+	{
+	}
+
+void LayoutAndCdlToCdlInstanceChecker::ApiNotInLeft(const CCdlTkApi& /*aApi*/)
+	{
+	iNotInLeft++;
+	}
+
+void LayoutAndCdlToCdlInstanceChecker::ApiNotInRight(const CCdlTkApi& aApi)
+	{
+	iNotInRight++;
+	cerr << aApi.Name() << " not in interface" << endl;
+	}
+
+
+int LayoutAndCdlToCdlInstance::Process(const vector<string>& args)
+	{
+	if (args.size() < 5 || args.size()%2 == 0)
+		throw LayoutAndCdlToCdlInstanceArgsErr();
+
+	string cdlName = args[2];
+	CCdlTkCdlFileParser parser(cdlName);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+
+	LayoutAndCdlToCdlInstance process(*iface);
+
+	TLayout* base = NULL;
+	for (int arg = 3; arg < args.size(); arg += 2)
+		{
+		string layoutName = args[arg];
+		string instName = args[arg+1];
+		auto_ptr<TLayParseLayout> layoutParse = TLayParseLayout::Parse(layoutName);
+		auto_ptr<TLayout> layout(layoutParse.get());
+		layoutParse.release();
+		if (base)
+			{
+			auto_ptr<TLayout> newLayout(new TLayout(*base));
+			newLayout->Merge(TLayout::KMergeModeVariant, *layout);
+			layout = newLayout;
+			}
+		else
+			{
+			base = layout.get();
+			}
+		process.AddLayout(layout, instName);
+		}
+
+	process.WriteInstances();
+
+	return 0;
+	}
+
+void LayoutAndCdlToCdlInstance::ShowHelp(ostream& stream)
+	{
+	stream << "LayCdl2Inst <cdlName> (<layoutName> <instanceName>)+ " << endl;
+	stream << "  Creates CDL instances containing the layout data." << endl;
+	stream << "  All layout instances must conform to the CDL interface." << endl;
+	stream << "  If more than one layout is supplied, subsequent ones are treated as" << endl;
+	stream << "  variants of the first." << endl;
+	}
+
+void LayoutAndCdlToCdlInstance::CheckLayoutAgainstInterface(const TLayout& aLayout, const CCdlTkInterface& aIface)
+	{
+	auto_ptr<CCdlTkInterface> layIface = LayoutToCdl::LayoutToInterface(aLayout);
+	LayoutAndCdlToCdlInstanceChecker checker;
+	CCdlTkApiChecker check(*layIface, aIface, checker);
+	check.Process();
+	}
+
+LayoutAndCdlToCdlInstance::LayoutAndCdlToCdlInstance(CCdlTkInterface& aInterface)
+: iInterface(aInterface)
+	{
+	}
+
+LayoutAndCdlToCdlInstance::~LayoutAndCdlToCdlInstance()
+	{
+	for (CLayouts::iterator pLayout = iLayouts.begin(); pLayout != iLayouts.end(); ++pLayout)
+		delete *pLayout;
+	}
+
+void LayoutAndCdlToCdlInstance::AddLayout(auto_ptr<TLayout>& aLayout, const string& aInstName)
+	{
+	CLayoutToInst* base = NULL;
+	if (iLayouts.size())
+		base = iLayouts[0];
+	auto_ptr<CLayoutToInst> p(new CLayoutToInst(base, iInterface, aLayout, aInstName));
+	iLayouts.push_back(p.get());
+	p.release();
+	}
+
+void LayoutAndCdlToCdlInstance::WriteInstances()
+	{
+	CLayouts::iterator pLayout = iLayouts.begin();
+	CLayouts::iterator end = iLayouts.end();
+	
+	if (pLayout!=end)
+		(*pLayout)->Process();
+
+	for (; pLayout != end; ++pLayout)
+		{
+		CCdlTkWriteInstance writer((*pLayout)->Instance());
+		writer.Process();
+		}
+	}
+
+
+CLayoutToInst::CLayoutToInst(CLayoutToInst* aBase, CCdlTkInterface& aInterface, auto_ptr<TLayout>& aLayout, const string& aInstName)
+: iBase(aBase), iInterface(aInterface), iLayout(*aLayout), iInstName(aInstName)
+	{
+	iLayoutPtr = aLayout.get();
+	aLayout.release();
+
+	iInstance = new CCdlTkInstance(iInterface);
+	iInstance->SetName(aInstName);
+
+	string extraCpp("#include <aknlayout2datadef.h>\n");
+	extraCpp += string("#include \"") + CdlTkUtil::ToLower(aBase ? aBase->FwdDeclName() : FwdDeclName()) + "\"\n";
+	iInstance->SetExtraCpp(extraCpp);
+
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		AddTableToInstance(**pTab);
+		}
+	}
+
+CLayoutToInst::~CLayoutToInst()
+	{
+	delete iInstance;
+	delete iLayoutPtr;
+	}
+
+string CLayoutToInst::FwdDeclName()
+	{
+	if (iBase)
+		return iBase->FwdDeclName();
+	else
+		return iInstName + ".FwdDecl.h";
+	}
+
+void CLayoutToInst::Process()
+	{
+	string fileName(FwdDeclName());
+	string interfaceNsName = iInterface.NamespaceName();
+
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	WriteHeaderGuardStart(fileName, stream);
+	stream << "namespace " << CdlTkUtil::ToCpp(iInstance->Name()) << endl;
+	stream << "{" << endl;
+
+	CCdlTkApiList& apiList = iInterface.ApiList();
+	for (CCdlTkApiList::iterator pApi = apiList.begin(); pApi != apiList.end(); ++pApi)
+		{
+		if ((*pApi)->IsFunc())
+			{
+			stream << "extern " << interfaceNsName << "::" << (*pApi)->AsFunc().ApiNameAsTypeName() << " " << (*pApi)->Name() << ";" << endl;
+			}
+		else
+			{
+			string typeExt = "Imp";
+			if ((*pApi)->ReturnType() == KTypeLayoutTableLimits)
+				typeExt = "";
+			stream << "extern " << (*pApi)->ReturnType() << typeExt << " const " << (*pApi)->Name() << ";" << endl;
+			}
+		}
+
+	stream << "}" << endl << endl;
+	WriteHeaderGuardEnd(fileName, stream);
+
+	stream.close();
+	CdlTkUtil::ExportFile(tempFile, CdlTkUtil::OutputPath() + fileName);
+	}
+
+CCdlTkInstance& CLayoutToInst::Instance()
+	{
+	return *iInstance;
+	}
+
+void CLayoutToInst::AddTableToInstance(TLayoutTable& aTable)
+	{
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		TLayoutLine& line = **pLine;
+		if (line.iIsMergedIdentical)
+			{
+			string apiName = LayoutToCdl::LineApiName(line);
+			AddFwdRefToInstance(apiName, false);
+
+			string multilineApiName = KFuncMultiline + apiName;
+			if (aTable.iType == TLayoutTable::ETextTable &&
+				line["B"].size() > 1 &&
+				HasApi(multilineApiName))
+				{
+				AddFwdRefToInstance(multilineApiName, false);
+				}
+			}
+		else
+			{
+			if (aTable.iType == TLayoutTable::EWindowTable)
+				AddWindowLineToInstance(line);
+			else
+				AddTextLineToInstance(line);
+			}
+		}
+
+	int tableNum = 0;
+	for (TLayoutTable::TLayoutSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+		{
+		TLayoutTable::TLayoutSubTable& sub = **pSub;
+		if (sub.iIsMergedIdentical)
+			{
+			AddFwdRefToInstance(LayoutToCdl::TableApiName(aTable, sub, tableNum)+KFuncLimitsSuffix, false);
+			AddFwdRefToInstance(LayoutToCdl::TableApiName(aTable, sub, tableNum), false);
+			}
+		else
+			{
+			AddTableLimitsToInstance(aTable, sub, tableNum);
+			string tableType = KTypeTextLineLayout;
+			if (aTable.iType == TLayoutTable::EWindowTable)
+				tableType = KTypeWindowLineLayout;
+			AddSubTableToInstance(tableType, aTable, sub, tableNum);
+			}
+		tableNum++;
+		}
+	}
+
+void CLayoutToInst::AddWindowLineToInstance(TLayoutLine& aLine)
+	{
+	string apiName = LayoutToCdl::LineApiName(aLine);
+	if (!HasApi(apiName))
+		return;
+	CCdlTkImplementation& imp = FindImp(apiName);
+	SetFuncLine(imp, aLine, KTypeWindowLineLayout, KWindowOutputOrder, KWindowOutputOrderSize, "", "");
+	}
+
+const string KMultiLineTextLineExtra = "\
+\tline.iB = KB[0];\n\
+\tline.iBaselineSkip = KB[1]-KB[0];\n\
+\tline.iNumberOfLinesShown = aNumberOfLinesShown;\n";
+
+const string KTextLineExtra = "\
+\tline.iBaselineSkip = 0;\n\
+\tline.iNumberOfLinesShown = 1;\n";
+
+void CLayoutToInst::AddTextLineToInstance(TLayoutLine& aLine)
+	{
+	string apiName = LayoutToCdl::LineApiName(aLine);
+	if (!HasApi(apiName))
+		return;
+	CCdlTkImplementation& imp = FindImp(apiName);
+	SetFuncLine(imp, aLine, KTypeTextLineLayout, KTextOutputOrder, KTextOutputOrderSize, "", KTextLineExtra);
+	if (aLine["B"].size() > 1)
+		{
+		string preExtra = "\tTInt " + KParamNameB + " = 0;\n";
+		if (aLine["B"].ParamName() != KParamNameB)
+			preExtra = "";
+		string apiName = KFuncMultiline + imp.Name();
+		if (HasApi(apiName))
+			{
+			CCdlTkImplementation& multiLineImp = FindImp(KFuncMultiline + imp.Name());
+			SetFuncLine(multiLineImp, aLine, KTypeMultiLineTextLayout, KTextOutputOrder, KTextOutputOrderSize, preExtra, KMultiLineTextLineExtra);
+			}
+		}
+	}
+
+bool CLayoutToInst::HasApi(const string& aName)
+	{
+	return iInterface.ApiList().Find(aName) != 0;
+	}
+
+CCdlTkImplementation& CLayoutToInst::FindImp(const string& aName)
+	{
+	CCdlTkImplementation* impl = iInstance->Impl().Find(aName);
+	if (!impl)
+		throw NotFoundErr(aName + " in interface " + iInterface.FileName());
+	return *impl;
+	}
+
+
+// subtable function uses the main table of pointers, with a mask to ensure that only correct lines are accessed
+// which are indexed by aLineIndex
+
+const string KSubTableImpl = "\
+#TYPE #NAME#PARAMLIST\n\
+\t{\n\
+\tstatic #PTRTYPE const * const KSubTableImpl = (#PTRTYPE const * const)&KCdlImpl.#FIRST_MEMBER;\n\
+\tASSERT(0<=" + KParamLineIndex + " && " + KParamLineIndex + "<32 && ((1<<" + KParamLineIndex + ") & #VALID_INDEX));\n\
+\t#PTRTYPE KImpl = KSubTableImpl[" + KParamLineIndex + "];\n\
+\treturn #EVAL;\n\
+\t}";
+
+const string KSubTableFuncEval = "(*KImpl)(#PARAMNAMES)";
+const string KSubTableDataEval = "*KImpl";
+
+void CLayoutToInst::AddSubTableToInstance(const string& aType, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aTableNum)
+	{
+	string apiName = LayoutToCdl::TableApiName(aTable, aSubTable, aTableNum);
+	if (!HasApi(apiName))
+		return;
+
+	CCdlTkImplementation& imp = FindImp(apiName);
+	const CCdlTkFunctionApi& api = imp.Api().AsFunc();
+	const CCdlTkApiParams& params = api.Params();
+
+	TLayoutLine& line = *aTable[aSubTable[0]];
+	CCdlTkImplementation& lineImp = FindImp(LayoutToCdl::LineApiName(line));
+	const CCdlTkApi& lineApi = lineImp.Api();
+
+	string ptrType;
+	if (lineApi.IsFunc())
+		ptrType = iInterface.NamespaceName() + "::" + lineApi.PointerType();
+	else
+		ptrType = lineApi.PointerType();
+	
+	int valid = 0;
+	for (int ii=0; ii<aTable.size(); ii++)
+		{
+		if (find(aSubTable.begin(), aSubTable.end(), ii) != aSubTable.end())
+			{
+			valid |= 1<<ii;
+			}
+		}
+
+	string firstMember = LayoutToCdl::LineApiName(*aTable[0]);
+
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add("#TYPE", aType);
+	implSet.Add("#NAME", imp.Name());
+	implSet.Add("#PARAMLIST", api.ParamsTypeAndNameList());
+	implSet.Add("#PTRTYPE", ptrType);
+	implSet.Add("#FIRST_MEMBER", firstMember);
+	implSet.Add("#VALID_INDEX", CdlTkUtil::IntToHexString(valid));
+	implSet.Add("#EVAL", lineApi.IsFunc() ?
+			CdlTkUtil::Replace("#PARAMNAMES", lineApi.AsFunc().ParamNameList(), KSubTableFuncEval) :
+			KSubTableDataEval);
+	string impl = CdlTkUtil::MultiReplace(implSet, KSubTableImpl);
+
+	imp.SetTemplatePointerReference();
+	imp.SetDefinition(impl);
+	}
+
+const string KTableLimitsImpl =
+KTypeLayoutTableLimits + " #NAME()\n\
+\t{\n\
+\tconst " + KTypeLayoutTableLimits + " limits = {#FIRST, #LAST};\n\
+\treturn limits;\n\
+\t}";
+
+void CLayoutToInst::AddTableLimitsToInstance(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSubTable, int aTableNum)
+	{
+	string apiName = LayoutToCdl::TableApiName(aTable, aSubTable, aTableNum)+KFuncLimitsSuffix;
+	if (!HasApi(apiName))
+		return;
+
+	CCdlTkImplementation& imp = FindImp(apiName);
+
+	int first = *aSubTable.begin();
+	int last = *aSubTable.rbegin();
+
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add("#NAME", imp.Name());
+	implSet.Add("#FIRST", CdlTkUtil::IntToString(first));
+	implSet.Add("#LAST", CdlTkUtil::IntToString(last));
+	string impl = CdlTkUtil::MultiReplace(implSet, KTableLimitsImpl);
+
+	imp.SetTemplatePointerReference();
+	imp.SetDefinition(impl);
+	}
+
+
+// data implementation is a simple const static data declaration
+
+const string KDataImpl = "const #TYPEImp #NAME = {#DATA};";
+const string KDataPtr = "(#TYPE*)&#NAME";
+
+void CLayoutToInst::SetDataLine(CCdlTkImplementation& aImp, TLayoutLine& aLine, const string& aType, const string aOutputOrder[], int aOutputOrderSize)
+	{
+	string data;
+	for (int ii=0; ii<aOutputOrderSize; ii++)
+		{
+		if (ii != 0)
+			data += ",";
+		string value = aLine[aOutputOrder[ii]][0];
+		CdlTkUtil::AppendString(data, TValues::CppValue(value));
+		}
+
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add("#TYPE", aType);
+	implSet.Add("#NAME", aImp.Name());
+	implSet.Add("#DATA", data);
+	string impl = CdlTkUtil::MultiReplace(implSet, KDataImpl);
+
+	CdlTkUtil::CReplaceSet ptrSet;
+	ptrSet.Add("#TYPE", aType);
+	ptrSet.Add("#NAME", aImp.Name());
+	string ptr = CdlTkUtil::MultiReplace(ptrSet, KDataPtr);
+
+	aImp.SetPointerReference(ptr);
+	aImp.SetDefinition(impl);
+	}
+
+
+// function implementation starts with asserts for parameter ranges and
+// tables of values for the parameterised cells.
+// The actual structure is initialised for the fixed values and indexed lookups
+// on the tables
+
+const string KFunctionImpl = "\
+#TYPE #NAME#PARAMTYPEANDNAMELIST\n\
+\t{\n\
+#PRE_EXTRA\
+#ASSERTS\
+#TABLES\
+\t#TYPEImp line = {#INIT};\n\
+#LOOKUPS\
+#POST_EXTRA\
+#RECT_ADJUST\
+\treturn line;\n\
+\t}";
+
+const string KFunctionAssert = "\tASSERT(0<=#PARAMNAME && #PARAMNAME<#PARAMLIMIT);\n";
+const string KFunctionTable = "\tconst static TInt16 K#TABLENAME[#PARAMLIMIT] = {#VALUES};\n";
+const string KFunctionLookup = "\tline.i#TABLENAME = K#TABLENAME[#PARAMNAME];\n";
+const string KFunctionRect = "\tline.SetAllParentOffsets(" + KParamParentRect + ");\n";
+
+void CLayoutToInst::SetFuncLine(CCdlTkImplementation& aImp, TLayoutLine& aLine, const string& aType, const string aOutputOrder[], int aOutputOrderSize, const string& aPreExtra, const string& aPostExtra)
+	{
+	const CCdlTkFunctionApi& api = aImp.Api().AsFunc();
+	const CCdlTkApiParams& params = api.Params();
+
+	string asserts;
+	string tables;
+	string init;
+	string lookups;
+	for (int ii=0; ii<aOutputOrderSize; ii++)
+		{
+		TValues& values = aLine[aOutputOrder[ii]];
+		const string& paramName = values.ParamName();
+		const string& paramLimit = CdlTkUtil::IntToString(values.size());
+		const string& tableName = aOutputOrder[ii];
+
+		if (ii != 0)
+			init += ",";
+		if (values.size() > 1)
+			{
+			string v;
+			for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+				{
+				if (pVal != values.begin())
+					v += ",";
+				v += TValues::CppValue(*pVal);
+				}
+
+			CdlTkUtil::CReplaceSet replaceSet;
+			replaceSet.Add("#PARAMNAME", paramName);
+			replaceSet.Add("#PARAMLIMIT", paramLimit); 
+			replaceSet.Add("#TABLENAME", tableName); 
+			replaceSet.Add("#VALUES", v); 
+
+			CdlTkUtil::AppendString(asserts, CdlTkUtil::MultiReplace(replaceSet, KFunctionAssert));
+			CdlTkUtil::AppendString(tables, CdlTkUtil::MultiReplace(replaceSet, KFunctionTable));
+			CdlTkUtil::AppendString(lookups, CdlTkUtil::MultiReplace(replaceSet, KFunctionLookup));
+			CdlTkUtil::AppendString(init, "0");
+			}
+		else
+			{
+			CdlTkUtil::AppendString(init, TValues::CppValue(values[0]));
+			}
+		}
+
+	string paramTypeAndNameList(api.ParamsTypeAndNameList());
+	if (aLine.iIsMirroredHorizontally)
+		MirrorParamNames(paramTypeAndNameList);
+
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add("#TYPE", aType);
+	implSet.Add("#NAME", api.Name());
+	implSet.Add("#PARAMTYPEANDNAMELIST", paramTypeAndNameList);
+	implSet.Add("#PRE_EXTRA", aPreExtra);
+	implSet.Add("#ASSERTS", asserts);
+	implSet.Add("#TABLES", tables);
+	implSet.Add("#INIT", init);
+	implSet.Add("#LOOKUPS", lookups);
+	implSet.Add("#POST_EXTRA", aPostExtra);
+	implSet.Add("#RECT_ADJUST", aLine.iNeedsP ? KFunctionRect : "");
+	string impl = CdlTkUtil::MultiReplace(implSet, KFunctionImpl);
+
+	aImp.SetTemplatePointerReference();
+	aImp.SetDefinition(impl);
+	}
+
+void CLayoutToInst::MirrorParamNames(std::string& aNames)
+	{
+	aNames = CdlTkUtil::Replace(KParamNameL, "__tmp__", aNames);
+	aNames = CdlTkUtil::Replace(KParamNameR, KParamNameL, aNames);
+	aNames = CdlTkUtil::Replace("__tmp__", KParamNameR, aNames);
+	}
+
+void CLayoutToInst::AddFwdRefToInstance(const string& aName, bool aCast)
+	{
+	string ns(CdlTkUtil::ToCpp(iBase->iInstance->Name()));
+	if (!HasApi(aName))
+		return;
+
+	CCdlTkImplementation& imp = FindImp(aName);
+	string ptr;
+	if (aCast)
+		ptr = string("(") + imp.Api().ReturnType() + "*)";
+	ptr += string("&") + ns + "::" + aName;
+	imp.SetPointerReference(ptr);
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayCdl2InstO.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,898 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayCdl2InstO.h"
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "CppWriter.h"
+#include "Lay2Cdl.h"
+#include "CodeGenConsts.h"
+#include <fstream>
+#include <algorithm>
+#include <iostream>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+#define AKNLAYOUT_DEFINE_BYTECODE(name,byte) const char name = char(byte);
+#include "AknLayoutByteCodes.h"
+
+
+extern string KMultiLine("Multiline_");
+typedef LayoutProcessArgsErr<LayoutCdlInstanceOpt> LayoutCdlInstanceOptArgsErr;
+
+
+/**
+*  gTheFuncs
+*  This is a collection of all SImplFunc objects that a layout instance needs, initialised
+*  so that there are up to four integer parameters per API type.
+*/
+CAllFuncs gTheFuncs(4);
+
+const string KDefinitionNotSet("Layout definition not found");
+
+
+CAllFuncs::CAllFuncs(int aMaxParams)
+	{
+	for (int ii=0; ii<=aMaxParams; ii++)
+		{
+		for (int jj=0; jj<2; jj++)
+			{
+			bool useParent = (jj == 1);
+			AddLineFunc(SImplFunc::EWindowLine, ii, useParent, KTypeWindowLineLayout, "WindowLine");
+			AddLineFunc(SImplFunc::ETextLine, ii, useParent, KTypeTextLineLayout, "TextLine");
+			AddLineFunc(SImplFunc::EMultilineTextLine, ii, useParent, KTypeMultiLineTextLayout, "MultiLineTextLine");
+			AddTableFunc(SImplFunc::EWindowTable, ii, useParent, KTypeWindowLineLayout, "WindowTable");
+			AddTableFunc(SImplFunc::ETextTable, ii, useParent, KTypeTextLineLayout, "TextTable");
+			}
+		}
+	SImplFunc limits(
+		SImplFunc::ETableLimits, 0, false,
+		KTypeLayoutTableLimits + " Limits() { return AknLayoutDecode::TableLimits(KDataLookup); }",
+		"&Limits");
+	push_back(limits);
+	}
+
+void CAllFuncs::AddLineFunc(SImplFunc::TFuncType aType, int aParams, bool aParent, const string& aReturn, const string& aFuncName)
+	{
+	// create a function of this form:
+	//TAknWindowLineLayout WindowTable$NUM$PARENT($PARAMS_TYPES_AND_NAMES)
+	//	{
+	//	return AknLayoutDecode::WindowLine$NUM$PARENT(&KImplData, $PARAM_NAMES);
+	//  }
+	string funcName = aFuncName + CdlTkUtil::IntToString(aParams) + (aParent ? "t" : "f");
+	string defn = aReturn + " " + funcName + "(";
+	string body = string(") { return AknLayoutDecode::") + funcName + "(&KImplData";
+
+	if (aParent)
+		{
+		defn += KTypeRect + " " + KParamParentRect;
+		body += ", " + KParamParentRect;
+		}
+
+	for (int ii=0; ii<aParams; ii++)
+		{
+		if (aParent || ii>0)
+			defn += ",";
+		defn += string(KTypeInt + " aParam") + CdlTkUtil::IntToString(ii);
+		body += string(", aParam") + CdlTkUtil::IntToString(ii);
+		}
+
+	defn += body + "); }";
+
+	string ptrRef = string("&") + funcName;
+
+	SImplFunc func(aType, aParams, aParent, defn, ptrRef);
+	push_back(func);
+	}
+
+void CAllFuncs::AddTableFunc(SImplFunc::TFuncType aType, int aParams, bool aParent, const string& aReturn, const string& aFuncName)
+	{
+	//Create a function of this form:
+	//TAknWindowLineLayout WindowTable$NUM$PARENT(TInt aLineIndex, $PARAMS_TYPES_AND_NAMES) 
+	//	{
+	//	return AknLayoutDecode::WindowTable$NUM$PARENT(&KImplData, aLineIndex, $PARAM_NAMES); 
+	//  }
+
+	string funcName = aFuncName + CdlTkUtil::IntToString(aParams) + (aParent ? "t" : "f");
+	string defn = aReturn + " " + funcName + "(" + KTypeInt + " " + KParamLineIndex;
+	string body = string(") { return AknLayoutDecode::") + funcName + "(&KImplData, " + KParamLineIndex;
+
+	if (aParent)
+		{
+		defn += ", " + KTypeRect + " " + KParamParentRect;
+		body += ", " + KParamParentRect;
+		}
+
+	for (int ii=0; ii<aParams; ii++)
+		{
+		defn += string(", " + KTypeInt + " aParam") + CdlTkUtil::IntToString(ii);
+		body += string(", aParam") + CdlTkUtil::IntToString(ii);
+		}
+
+	defn += body + "); }";
+
+	string ptrRef = string("&") + funcName;
+
+	SImplFunc func(aType, aParams, aParent, defn, ptrRef);
+	push_back(func);
+	}
+
+
+class CLayoutInstOptImpl
+	{
+public:
+	CLayoutInstOptImpl(TLayoutLine* aLine, CCdlTkImplementation* aImpl);
+	TLayoutLine* iLine;
+	CCdlTkImplementation* iImpl;
+	int iByteCodeIndex;
+	string iComment;
+	vector<char> iBytes;
+	};
+
+CLayoutInstOptImpl::CLayoutInstOptImpl(TLayoutLine* aLine, CCdlTkImplementation* aImpl)
+: iLine(aLine), iImpl(aImpl)
+	{
+	}
+
+
+class CLayoutInstOpt
+	{
+public:
+	CLayoutInstOpt(LayoutCdlInstanceOpt& aInstances, auto_ptr<TLayout>& aLayout, const string& aInstName);
+	~CLayoutInstOpt();
+
+	void Process();
+	void WriteInstance();
+
+	CCdlTkInstance& Inst() { return *iInstance; }
+
+private:
+	void ProcessTable(TLayoutTable& aTable);
+	void ProcessLine(TLayoutLine& aLine);
+	void ProcessLineApi(TLayoutLine& aLine, CCdlTkImplementation& aImpl);
+	void ProcessMultiLineApi(TLayoutLine& aLine, CCdlTkImplementation& aImpl);
+
+	void SetSimilarLineData(CLayoutInstOptImpl& aImpl, CLayoutInstOptImpl& aSimilar);
+	void SetNewLineData(CLayoutInstOptImpl& aImpl);
+	bool HasApi(const string& aName);
+	CCdlTkImplementation& FindImp(const string& aName);
+	void SetLineFunc(CLayoutInstOptImpl& aImpl);
+
+	void CountApiParams(CCdlTkImplementation& aApi, int& aParams, bool& aParent);
+	SImplFunc& AddImplFunc(SImplFunc::TFuncType aType, int iParams, bool aParent);
+
+	void SetExtraCpp();
+
+	void AddTableToInstance(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSub, int aTableNum);
+	void AddTableLimitsImpl(const string& aApiName, TLayoutTable::TLayoutSubTable& aSubTable);
+	void AddTableImpl(const string& aApiName, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSub);
+
+	void EncodeValue(vector<char>& aBytes, string aValue);
+
+	void MirrorParamName(string& aParamName);
+
+private:
+	LayoutCdlInstanceOpt& iInstances;
+	TLayout* iLayout;
+	string iName;
+	CCdlTkInterface& iInterface;
+	CCdlTkInstance* iInstance;
+	CLayoutInstOptImpls iImpls;
+	typedef vector<SImplFunc*> CImplFuncs;
+	CImplFuncs iFuncs;
+	};
+
+CLayoutInstOpt::CLayoutInstOpt(LayoutCdlInstanceOpt& aInstances, auto_ptr<TLayout>& aLayout, const string& aInstName)
+: iInstances(aInstances), iName(aInstName), iInterface(iInstances.Interface())
+	{
+	iLayout = aLayout.get();
+	aLayout.release();
+
+	iInstance = new CCdlTkInstance(iInterface);
+	iInstance->SetName(aInstName);
+
+	// Initially set definitions that will not compile in the resulting code.
+	// This will alert the programmer to missing layout data.
+	CCdlTkImplementations& impl = iInstance->Impl();
+	for (CCdlTkImplementations::iterator pImpl = impl.begin(); pImpl != impl.end(); ++pImpl)
+		(*pImpl)->SetDefinition(KDefinitionNotSet);
+	}
+
+CLayoutInstOpt::~CLayoutInstOpt()
+	{
+	delete iLayout;
+	delete iInstance;
+	for (CLayoutInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		delete *pImpl;
+	}
+
+void CLayoutInstOpt::Process()
+	{
+	for (TLayout::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab)
+		ProcessTable(**pTab);
+	SetExtraCpp();
+	}
+
+void CLayoutInstOpt::WriteInstance()
+	{
+	CCdlTkWriteInstance writer(*iInstance);
+	writer.Process();
+	}
+
+void CLayoutInstOpt::ProcessTable(TLayoutTable& aTable)
+	{
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		ProcessLine(**pLine);
+
+	int tableNum = 0;
+	for (TLayoutTable::TLayoutSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+		{
+		TLayoutTable::TLayoutSubTable& sub = **pSub;
+		AddTableToInstance(aTable, sub, tableNum);
+		tableNum++;
+		}
+	}
+
+void CLayoutInstOpt::ProcessLine(TLayoutLine& aLine)
+	{
+	string apiName = LayoutToCdl::LineApiName(aLine);
+	if (!HasApi(apiName))
+		return;
+
+	ProcessLineApi(aLine, FindImp(apiName));
+
+	string multilineApiName = KFuncMultiline + apiName;
+	if (aLine.iTable->iType == TLayoutTable::ETextTable &&
+		aLine["B"].size() > 1 &&
+		HasApi(multilineApiName))
+		ProcessMultiLineApi(aLine, FindImp(multilineApiName));
+	}
+
+void CLayoutInstOpt::ProcessLineApi(TLayoutLine& aLine, CCdlTkImplementation& aImpl)
+	{
+	CLayoutInstOptImpl* newImpl = new CLayoutInstOptImpl(&aLine, &aImpl);
+	iImpls.push_back(newImpl);
+
+	// always set the new line data
+	SetNewLineData(*newImpl);
+
+	// if we can find the new line data in the aggregated data, point to that instead
+	int foundIndex = iInstances.FindSimilarBytes(newImpl);
+	if(foundIndex >= 0)
+		{
+		newImpl->iByteCodeIndex = foundIndex;
+		newImpl->iBytes.clear();
+		}
+
+	SetLineFunc(*newImpl);
+	iInstances.AddImpl(newImpl);
+	newImpl->iImpl->SetDefinition(CdlTkUtil::ShortToHexString(newImpl->iByteCodeIndex) + ",\t// " + LayoutToCdl::LineApiName(aLine));
+	}
+
+void CLayoutInstOpt::ProcessMultiLineApi(TLayoutLine& aLine, CCdlTkImplementation& aImpl)
+	{
+	CLayoutInstOptImpl* newImpl = new CLayoutInstOptImpl(&aLine, &aImpl);
+	iImpls.push_back(newImpl);
+
+	CCdlTkImplementation& textImpl = FindImp(LayoutToCdl::LineApiName(aLine));
+
+	// locate the position of the "aIndex_B" paramters in the text API parameter list
+	// and the position of the "aNumberOfLinesShown" parameter in the multiline API
+	// parmeter list. This is all the info needed to implement multiline APIs in terms
+	// of the corresponding text API
+	int bPos = 4, lPos = 0;
+	const CCdlTkApiParams& mParams = aImpl.Api().AsFunc().Params();
+	const CCdlTkApiParams& tParams = textImpl.Api().AsFunc().Params();
+	CCdlTkApiParams::const_iterator pMParam = mParams.begin(); 
+	CCdlTkApiParams::const_iterator pTParam = tParams.begin();
+	int ii=0;
+	while (pMParam != mParams.end() || pTParam != tParams.end())
+		{
+		if (pTParam != tParams.end())
+			{
+			if (pTParam->Name() == KParamNameB)
+				bPos = ii;
+			++pTParam;
+			}
+		if (pMParam != mParams.end())
+			{
+			if (pMParam->Name() == KParamNameNumberOfLinesShown)
+				lPos = ii;
+			++pMParam;
+			}
+		ii++;
+		}
+
+	SetLineFunc(*newImpl);
+	iInstances.AddImpl(newImpl);
+	newImpl->iImpl->SetDefinition(CdlTkUtil::ShortToHexString((bPos<<8)|lPos) + ",\t// " + aImpl.Name());
+	}
+
+
+void CLayoutInstOpt::SetSimilarLineData(CLayoutInstOptImpl& aImpl, CLayoutInstOptImpl& aSimilar)
+	{
+	aImpl.iByteCodeIndex = aSimilar.iByteCodeIndex;
+	}
+
+void CLayoutInstOpt::SetNewLineData(CLayoutInstOptImpl& aImpl)
+	{
+	TLayoutLine& line = *aImpl.iLine;
+
+	// set comment
+	aImpl.iComment = string("for ") + LayoutToCdl::LineApiName(line);
+
+	const string* outputOrder = KWindowOutputOrder;
+	int outputSize = KWindowOutputOrderSize;
+	if (line.iTable->iType == TLayoutTable::ETextTable)
+		{
+		outputOrder = KTextOutputOrder;
+		outputSize = KTextOutputOrderSize;
+		}
+
+	// encode parameters
+	const CCdlTkApiParams& params = aImpl.iImpl->Api().AsFunc().Params();
+	for (CCdlTkApiParams::const_iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		{
+		const CCdlTkApiParam& param = *pParam;
+		if (param.Type() == KTypeInt)	// is it a cell index parameter
+			{
+			string paramName = param.Name();
+			if (line.iIsMirroredHorizontally)
+				MirrorParamName(paramName);
+			char cells = 0;		// bit field for cells that this parameter applies to
+			char maxVal = 0;
+			char nextCell = 1;	// bit flag for the next cell
+			for (int ii=0; ii<outputSize; ii++)
+				{
+				TValues& values = line[outputOrder[ii]];
+				if (values.iNeedsIndex && values.ParamName() == paramName)
+					{
+					if (maxVal == 0)
+						maxVal = values.size();
+					else if (maxVal != values.size())
+						throw CdlTkAssert(string("param range mismatch ") + line.Name() + " " + param.Name());
+					cells |= nextCell;
+					}
+				nextCell = nextCell << 1;
+				}
+			aImpl.iBytes.push_back(cells);
+			aImpl.iBytes.push_back(maxVal);
+			}
+		}
+
+	// encode data
+	for (int ii=0; ii<outputSize; ii++)
+		{
+		TValues& values = line[outputOrder[ii]];
+		for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+			EncodeValue(aImpl.iBytes, *pVal);
+		}
+	}
+
+void CLayoutInstOpt::CountApiParams(CCdlTkImplementation& aApi, int& aParams, bool& aParent)
+	{
+	aParams = 0;
+	aParent = false;
+	const CCdlTkApiParams& params = aApi.Api().AsFunc().Params();
+	for (CCdlTkApiParams::const_iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		{
+		if (pParam->Type() == KTypeInt) // is it a cell index parameter
+			aParams++;
+		else
+			aParent = true;
+		}
+	}
+
+void CLayoutInstOpt::SetLineFunc(CLayoutInstOptImpl& aImpl)
+	{
+	int nParams;
+	bool hasParent;
+	CountApiParams(*aImpl.iImpl, nParams, hasParent);
+
+	SImplFunc::TFuncType type = SImplFunc::EWindowLine;
+	if (aImpl.iLine->iTable->iType == TLayoutTable::ETextTable)
+		{
+		type = SImplFunc::ETextLine;
+		string name = aImpl.iImpl->Name();
+		if (name.size() > KFuncMultiline.size() && name.substr(0,KFuncMultiline.size()) == KFuncMultiline)
+			type = SImplFunc::EMultilineTextLine;
+		}
+
+	SImplFunc& func = AddImplFunc(type, nParams, hasParent);
+	aImpl.iImpl->SetPointerReference(func.iPtrRef);
+	}
+
+CCdlTkImplementation& CLayoutInstOpt::FindImp(const string& aName)
+	{
+	CCdlTkImplementation* impl = iInstance->Impl().Find(aName);
+	if (!impl)
+		throw NotFoundErr(aName + " in interface " + iInterface.FileName());
+	return *impl;
+	}
+
+bool CLayoutInstOpt::HasApi(const string& aName)
+	{
+	return iInterface.ApiList().Find(aName) != 0;
+	}
+
+SImplFunc& CLayoutInstOpt::AddImplFunc(SImplFunc::TFuncType aType, int aParams, bool aParent)
+	{
+	for (CImplFuncs::iterator pFunc = iFuncs.begin(); pFunc != iFuncs.end(); ++pFunc)
+		{
+		SImplFunc& func = **pFunc;
+		if (func.iType == aType && func.iParams == aParams && func.iParent == aParent)
+			return func;
+		}
+
+	int count = gTheFuncs.size();
+	for (int ii=0; ii<count; ii++)
+		{
+		SImplFunc* func = &gTheFuncs[ii];
+		if (func->iType == aType && func->iParams == aParams && func->iParent == aParent)
+			{
+			iFuncs.push_back(func);
+			return *func;
+			}
+		}
+
+	throw NotFoundErr("implementation function");
+	return gTheFuncs[0];
+	}
+
+// The following strings and the SetExtraCpp() function build the gross structure of
+// the C++ customisation instance.
+// So far, the implementations are actually just 16-bit values, typically indexes into
+// the data lookup table. These need to be turned into an array by adding declarations
+// and brackets to the first and last implementations. Extra support functions are also
+// added.
+extern string KExtraCpp = "\
+#include \"aknlayout2decode.h\"\n\
+namespace $INTERFACE_NS { extern const TUint8 KByteCodedData[]; }\n";
+
+extern string KInitialCpp ="\
+extern const TUint16 KDataLookup[$INTERFACE_NS::E_TApiId_TableSize];\n\
+const SImplData KImplData = { KDataLookup, $INTERFACE_NS::KByteCodedData };\n\
+\n\
+$FUNCTIONS\
+\n\
+const TUint16 KDataLookup[$INTERFACE_NS::E_TApiId_TableSize] =\n\
+\t{\n";
+
+void CLayoutInstOpt::SetExtraCpp()
+	{
+	// The "extra cpp" field is written to the top of the cpp file.
+	iInstance->SetExtraCpp(CdlTkUtil::Replace("$INTERFACE_NS", iInterface.NamespaceName(), KExtraCpp));
+
+	// add headers & fwd declarations
+	string init = CdlTkUtil::Replace("$INTERFACE_NS", iInterface.NamespaceName(), KInitialCpp);
+
+	// add decode functions
+	string functions;
+	for (CImplFuncs::iterator pFunc = iFuncs.begin(); pFunc != iFuncs.end(); ++pFunc)
+		{
+		CdlTkUtil::AppendString(functions, (*pFunc)->iDefn);
+		CdlTkUtil::AppendString(functions, "\n");
+		}
+	init = CdlTkUtil::Replace("$FUNCTIONS", functions, init);
+	CCdlTkImplementation& first = **(iInstance->Impl().begin());
+	first.SetDefinition(init + first.Definition());
+
+	// add end of data table
+	CCdlTkImplementation& last = **(iInstance->Impl().end() - 1);
+	last.SetDefinition(last.Definition() + "\n};");
+	}
+
+void CLayoutInstOpt::AddTableToInstance(TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSub, int aTableNum)
+	{
+	string tableName = LayoutToCdl::TableApiName(aTable, aSub, aTableNum);
+	if (HasApi(tableName))
+		{
+		AddTableLimitsImpl(tableName + KFuncLimitsSuffix, aSub);
+		AddTableImpl(tableName, aTable, aSub);
+		}
+	}
+
+void CLayoutInstOpt::AddTableLimitsImpl(const string& aApiName, TLayoutTable::TLayoutSubTable& aSubTable)
+	{
+	// code up table limits as a pair of byte values, the first byte is the first table
+	// index, the second is the last table index.
+	CCdlTkImplementation& impl = FindImp(aApiName);
+	int first = (*aSubTable.begin()) & 0xff;
+	int last = (*aSubTable.rbegin()) & 0xff;
+	impl.SetDefinition(CdlTkUtil::ShortToHexString((first<<8)|last) + ",");
+	impl.SetPointerReference(AddImplFunc(SImplFunc::ETableLimits, 0, false).iPtrRef);
+	}
+
+void CLayoutInstOpt::AddTableImpl(const string& aApiName, TLayoutTable& aTable, TLayoutTable::TLayoutSubTable& aSub)
+	{
+	CCdlTkImplementation& impl = FindImp(aApiName);
+
+	int nParams;
+	bool hasParent;
+	CountApiParams(impl, nParams, hasParent);
+	nParams--;	// don't count the aLineIndex param
+	SImplFunc::TFuncType type = SImplFunc::EWindowTable;
+	if (aTable.iType == TLayoutTable::ETextTable)
+		type = SImplFunc::ETextTable;
+
+	SImplFunc& func = AddImplFunc(type, nParams, hasParent);
+
+	impl.SetDefinition(string("(TUint16)") + iInterface.NamespaceName() + "::EApiId_" + LayoutToCdl::LineApiName(*aTable[0]) + ",");
+	impl.SetPointerReference(func.iPtrRef);
+	}
+
+struct SIdToInt
+	{
+	int iInt;
+	char* iStr;
+	};
+
+#include <avkon.hrh>
+const int KScalableFontIdOffset(0x1000);
+extern SIdToInt gIdToIntTable[] =
+	{
+		{ ELayoutAlignLeft, "ELayoutAlignLeft" },
+		{ ELayoutAlignRight, "ELayoutAlignRight" },
+		{ ELayoutAlignCenter, "ELayoutAlignCenter" },
+		{ ELayoutAlignBidi, "ELayoutAlignBidi" },
+		{ ELatinBold19, "ELatinBold19" },
+		{ ELatinBold17, "ELatinBold17" },
+		{ ELatinBold13, "ELatinBold13" },
+		{ ELatinBold12, "ELatinBold12" },
+		{ ELatinPlain12, "ELatinPlain12" },
+		{ ELatinClock14, "ELatinClock14" },
+		{ EApacPlain12, "EApacPlain12" },	
+		{ EApacPlain16, "EApacPlain16" },
+		{ ENumberPlain5, "ENumberPlain5" },
+		{ ELatinBold16, "ELatinBold16" },
+
+		{ ELatinBold19+KScalableFontIdOffset, "ELatinBold19_Scaled" },
+		{ ELatinBold17+KScalableFontIdOffset, "ELatinBold17_Scaled" },
+		{ ELatinBold13+KScalableFontIdOffset, "ELatinBold13_Scaled" },
+		{ ELatinBold12+KScalableFontIdOffset, "ELatinBold12_Scaled" },
+		{ ELatinPlain12+KScalableFontIdOffset, "ELatinPlain12_Scaled" },
+		{ ELatinClock14+KScalableFontIdOffset, "ELatinClock14_Scaled" },
+		{ EApacPlain12+KScalableFontIdOffset, "EApacPlain12_Scaled" },	
+		{ EApacPlain16+KScalableFontIdOffset, "EApacPlain16_Scaled" },
+		{ ENumberPlain5+KScalableFontIdOffset, "ENumberPlain5_Scaled" },
+		{ ELatinBold16+KScalableFontIdOffset, "ELatinBold16_Scaled" },
+
+		{ 100, "qfn_latin_plain_17" },		// fonts that appear in app laf
+		{ ECalcBold21, "ECalcBold21" },
+		{ ECalcOperBold21, "ECalcOperBold21" },
+		{ ECalcOperBold13, "ECalcOperBold13" },
+		{ 100, "gfn_latin_bold_13" },
+		{ 100, "gfn_latin_plain_12" },
+		{ 100, "qfn_clock_plain_5" },
+
+		{ 100, "qfn_latin_plain_17_Scaled" },
+		{ ECalcBold21+KScalableFontIdOffset, "ECalcBold21_Scaled" },
+		{ ECalcOperBold21+KScalableFontIdOffset, "ECalcOperBold21_Scaled" },
+		{ ECalcOperBold13+KScalableFontIdOffset, "ECalcOperBold13_Scaled" },
+		{ 100, "gfn_latin_bold_13_Scaled" },
+		{ 100, "gfn_latin_plain_12_Scaled" },
+		{ 100, "qfn_clock_plain_5_Scaled" }
+
+	};
+extern const int gIdToIntTableCount = sizeof(gIdToIntTable)/sizeof(SIdToInt);
+
+extern void TranslateValue(string& aValue)
+	{
+	int count = gIdToIntTableCount;
+	for (int ii=0; ii<count; ii++)
+		{
+		SIdToInt& trans = gIdToIntTable[ii];
+		if (aValue == trans.iStr)
+			{
+			aValue = CdlTkUtil::IntToString(trans.iInt);
+			return;
+			}
+		}
+	}
+
+void CLayoutInstOpt::EncodeValue(vector<char>& aBytes, string aValue)
+	{
+	int pos;
+	TranslateValue(aValue);
+
+	if (aValue == "")
+		{
+		aBytes.push_back(KByteEmpty);
+		}
+	else if ((pos = aValue.find('p')) != string::npos)
+		{
+		if (pos != 0)
+			throw CdlTkAssert(string("arithmetic parser not good enough : ") + aValue);
+		int val = CdlTkUtil::ParseInt(aValue.substr(1));
+		if (-128 <= val && val <= 127)
+			{
+			aBytes.push_back(KByteP1);
+			aBytes.push_back(val);
+			}
+		else
+			{
+			aBytes.push_back(KByteP2);
+			aBytes.push_back((val & 0xff00) >> 8);
+			aBytes.push_back(val);
+			}
+		}
+	else
+		{
+		int val = CdlTkUtil::ParseInt(aValue);
+		if (0 <= val && val <= KMaxSingleByteValue)
+			{
+			aBytes.push_back(val);
+			}
+		else
+			{
+			aBytes.push_back(KByteWord);
+			aBytes.push_back((val & 0xff00) >> 8);
+			aBytes.push_back(val);
+			}
+		}
+	}
+
+void CLayoutInstOpt::MirrorParamName(string& aParamName)
+	{
+	if (aParamName == KParamNameL)
+		aParamName = KParamNameR;
+	else if (aParamName == KParamNameR)
+		aParamName = KParamNameL;
+	}
+
+
+
+//
+// CInstanceList
+//
+
+void CInstanceList::ProcessOptions(vector<string>& aArgs)
+	{
+	bool instanceFileOk = false;
+	iLoaded = false;
+	string instFile;
+	for(vector<string>::iterator pArg = aArgs.begin(); pArg != aArgs.end(); ++pArg)
+		{
+		string& arg = *pArg;
+		if (arg.size() >= 2 && arg.substr(0,2) == "-i")
+			{
+			instFile = arg.substr(2);
+			aArgs.erase(pArg);
+			instanceFileOk = true;
+			break;
+			}
+		}
+	if(!instanceFileOk)
+		throw LayoutCdlInstanceOptArgsErr();
+	ifstream in;
+	CdlTkUtil::OpenInput(in, instFile);
+	iLoaded = true;
+	string line;
+	while (!in.eof())
+		{
+		getline(in, line);
+		iInstances.insert(line);
+		}
+	in.close();
+	}
+
+bool CInstanceList::IsInstanceOk(const string& aInstance) const
+	{
+	return (!iLoaded || iInstances.find(aInstance) != iInstances.end());
+	}
+
+
+//
+// LayoutCdlInstanceOpt
+//
+
+int LayoutCdlInstanceOpt::Process(vector<string>& args)
+	{
+	CInstanceList instList;
+	instList.ProcessOptions(args);
+
+	int extraArgs = args.size() - 5;
+	if (extraArgs < 0 || extraArgs%2 == 1)
+		throw LayoutCdlInstanceOptArgsErr();
+
+	string cdlName = args[2];
+	CCdlTkCdlFileParser parser(cdlName);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+
+	LayoutCdlInstanceOpt process(*iface);
+
+	TLayout* base = NULL;
+	for (int arg = 3; arg < args.size(); arg += 2)
+		{
+		string layoutName = args[arg];
+		string instName = args[arg+1];
+		if (!instList.IsInstanceOk(instName))
+			continue;
+
+		auto_ptr<TLayParseLayout> layoutParse = TLayParseLayout::Parse(layoutName);
+		auto_ptr<TLayout> layout(layoutParse.get());
+		layoutParse.release();
+		if (base)
+			{
+			auto_ptr<TLayout> newLayout(new TLayout(*base));
+			newLayout->Merge(TLayout::KMergeModeVariant, *layout);
+			layout = newLayout;
+			}
+		else
+			{
+			base = layout.get();
+			}
+		process.AddLayout(layout, instName);
+		}
+
+	if (base)
+		{
+		process.Process();
+		process.WriteInstances();
+		}
+
+	return 0;
+	}
+
+void LayoutCdlInstanceOpt::ShowHelp(ostream& stream)
+	{
+	stream << "LayCdl2InstO [-i<instanceList>] <cdlName> (<layoutName> <instanceName>)+ " << endl;
+	stream << "  Creates optimised CDL instances containing the layout data." << endl;
+	stream << "  All layout instances must conform to the CDL interface." << endl;
+	stream << "  If more than one layout is supplies, subsequent ones are treated as" << endl;
+	stream << "  variants of the first." << endl;
+	stream << "  If -i<instanceList> is specified, then only instances whose name" << endl;
+	stream << "  appears in the file <instanceList> will be processed" << endl;
+	}
+
+LayoutCdlInstanceOpt::LayoutCdlInstanceOpt(CCdlTkInterface& aInterface)
+: iInterface(aInterface), iByteCodeIndex(0)
+	{
+	}
+
+LayoutCdlInstanceOpt::~LayoutCdlInstanceOpt()
+	{
+	for (CLayouts::iterator pLayout = iLayouts.begin(); pLayout != iLayouts.end(); ++pLayout)
+		delete *pLayout;
+	}
+
+void LayoutCdlInstanceOpt::AddLayout(auto_ptr<TLayout>& aLayout, const string& aInstName)
+	{
+	auto_ptr<CLayoutInstOpt> p(new CLayoutInstOpt(*this, aLayout, aInstName));
+	iLayouts.push_back(p.get());
+	p.release();
+	}
+
+void LayoutCdlInstanceOpt::Process()
+	{
+	for (CLayouts::iterator pLayout = iLayouts.begin(); pLayout != iLayouts.end(); ++pLayout)
+		(*pLayout)->Process();
+	ProcessCommonImpl();
+	}
+
+void LayoutCdlInstanceOpt::WriteInstances()
+	{
+	for (CLayouts::iterator pLayout = iLayouts.begin(); pLayout != iLayouts.end(); ++pLayout)
+		(*pLayout)->WriteInstance();
+	}
+
+CCdlTkInterface& LayoutCdlInstanceOpt::Interface()
+	{
+	return iInterface;
+	}
+
+const string KCommonImplStart = "\
+#include \"aknlayout2decode.h\"\n\
+namespace $NAMESPACENAME { extern TUint8 const KByteCodedData[] = {\n";
+
+const string KCommonImplImpl = "\
+// $INDEX $COMMENT\n\
+$BYTES\n";
+
+void LayoutCdlInstanceOpt::ProcessCommonImpl()
+	{
+	string bytecode = CdlTkUtil::Replace("$NAMESPACENAME", iInterface.NamespaceName(), KCommonImplStart);
+
+	for (CLayoutInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		{
+		vector<char>& bytes = (*pImpl)->iBytes;
+		if (bytes.size())
+			{
+			string byteString;
+			for (vector<char>::iterator pChar = bytes.begin(); pChar != bytes.end(); ++pChar)
+				{
+				CdlTkUtil::AppendString(byteString, CdlTkUtil::CharToHexString(*pChar));
+				CdlTkUtil::AppendString(byteString, ",");
+				}
+
+			CdlTkUtil::CReplaceSet implSet;
+			implSet.Add("$INDEX", CdlTkUtil::ShortToHexString((*pImpl)->iByteCodeIndex));
+			implSet.Add("$COMMENT", (*pImpl)->iComment);
+			implSet.Add("$BYTES", byteString);
+			CdlTkUtil::AppendString(bytecode, CdlTkUtil::MultiReplace(implSet, KCommonImplImpl));
+			}
+		}
+	CdlTkUtil::AppendString(bytecode, "};\n}");
+
+	CCdlTkInstance& firstInst = iLayouts[0]->Inst();
+	firstInst.SetExtraCpp(bytecode);
+	}
+
+LayoutCdlInstanceOpt::CLayouts& LayoutCdlInstanceOpt::Layouts()
+	{
+	return iLayouts;
+	}
+
+CLayoutInstOptImpl* LayoutCdlInstanceOpt::FindSimilarImpl(TLayoutLine& aLine)
+	{
+	for (CLayoutInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		{
+		CLayoutInstOptImpl* impl = *pImpl;
+		if (LinesAreEqual(*impl->iLine, aLine))
+			{
+			return impl;
+			}
+		}
+	return NULL;
+	}
+
+int LayoutCdlInstanceOpt::FindSimilarBytes(CLayoutInstOptImpl* aImpl)
+	{
+	int index = -1;
+	vector<char>::iterator found = std::search(
+		iBytesAggregated.begin(), 
+		iBytesAggregated.end(), 
+		aImpl->iBytes.begin(), 
+		aImpl->iBytes.end());
+	if(found != iBytesAggregated.end())
+		{
+		index = std::distance(iBytesAggregated.begin(), found);
+		}
+	return index;
+	}
+
+void LayoutCdlInstanceOpt::AddImpl(CLayoutInstOptImpl* aImpl)
+	{
+	iImpls.push_back(aImpl);
+	int bytesAdded = aImpl->iBytes.size();
+	if (bytesAdded)
+		{
+		aImpl->iByteCodeIndex = iByteCodeIndex;
+		iByteCodeIndex += bytesAdded;
+		iBytesAggregated.insert(
+			iBytesAggregated.end(), 
+			aImpl->iBytes.begin(), 
+			aImpl->iBytes.end());
+		}
+	}
+
+bool LayoutCdlInstanceOpt::LinesAreEqual(TLayoutLine& aLine1, TLayoutLine& aLine2)
+	{
+	TLayoutLine::iterator pValues1 = aLine1.begin();
+	TLayoutLine::iterator pValues2 = aLine2.begin();
+	for (; pValues1 != aLine1.end() && pValues2 != aLine2.end(); ++pValues1, ++pValues2)
+		{
+		if (TLayoutTable::IsValueColumn(pValues1->first) && *pValues1 != *pValues2)
+			return false;
+		}
+	return true;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayCdlCheck.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,206 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayCdlCheck.h"
+#include <iostream>
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "Lay2Cdl.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+
+typedef LayoutProcessArgsErr<LayCdlCheck> LayCdlCheckArgsErr;
+
+const string KDefaultLayCdlCheckOptions = "lcm";
+
+int LayCdlCheck::Process(const vector<string>& args)
+	{
+	if (args.size() < 4)
+		throw LayCdlCheckArgsErr();
+
+	int nextArg = 2;
+	string opt = args[nextArg];
+	if (opt.size() >= 2 && opt.substr(0,2) == "-o")
+		{
+		nextArg++;
+		opt = opt.substr(2);
+		}
+	else
+		{
+		opt = KDefaultLayCdlCheckOptions;
+		}
+
+	string layoutName = args[nextArg++];
+	auto_ptr<TLayParseLayout> layout(TLayParseLayout::Parse(layoutName));
+	auto_ptr<CCdlTkInterface> iface(new CCdlTkInterface);
+	CCdlTkApiList& apiList = iface->ApiList();
+	auto_ptr<CCdlTkInterface> xIface(new CCdlTkInterface);
+	CCdlTkApiList& xApiList = xIface->ApiList();
+
+	for (int arg = nextArg; arg < args.size(); arg++)
+		{
+		string fileName = args[arg];
+		if (fileName.size() < 4)
+			throw LayCdlCheckArgsErr();
+		string ext = CdlTkUtil::ToLower(fileName.substr(fileName.size()-4));
+
+		if (ext == ".lay")
+			{
+			auto_ptr<TLayParseLayout> nextLayout(TLayParseLayout::Parse(fileName));
+			layout->Merge(TLayout::KMergeModeVariant, *nextLayout);
+			}
+		else if (ext == ".cdl")
+			{
+			CCdlTkApiList* pApiList = &apiList;
+			if (fileName.substr(0,2) == "-x")
+				{
+				pApiList = &xApiList;
+				fileName = fileName.substr(2);
+				}
+			CCdlTkCdlFileParser parser(fileName);
+			auto_ptr<CCdlTkInterface> nextIface(parser.LoadAndParse(true));
+			CCdlTkApiList& nextApi = nextIface->ApiList();
+			for (CCdlTkApiList::iterator pApi = nextApi.begin(); pApi != nextApi.end(); ++pApi)
+				pApiList->push_back((*pApi)->Clone(*iface));
+			}
+		else
+			throw LayCdlCheckArgsErr();
+		}
+
+	LayCdlCheck process(*layout, *iface, *xIface, opt);
+	process.Process();
+
+	return 0;
+	}
+
+void LayCdlCheck::ShowHelp(ostream& stream)
+	{
+	stream << "LayCdlCheck [-o[glcm]] <layoutName>* <cdlName>* [-x<cdlName>*]" << endl;
+	stream << "  Compare API for lay files against CDL interfaces" << endl;
+	stream << "  -o[glcm] (default = -olcm) -  show output for:" << endl;
+	stream << "    g = good matches" << endl;
+	stream << "    l = lay file only" << endl;
+	stream << "    c = CDL interface only" << endl;
+	stream << "    m = mismatches" << endl;
+	stream << "  Where multiple <layoutName> are specified, the layouts are merged with variant mode." << endl;
+	stream << "  Where multiple <cdlName> are specified, the CDL interfaces are added together." << endl;
+	stream << "  -x<cdlName> - exclude APIs in <cdlName> from the report." << endl;
+	}
+
+
+LayCdlCheck::LayCdlCheck(TLayout& aLayout, CCdlTkInterface& aInterface, CCdlTkInterface& aExcluded, const string& aOpt)
+: iLayout(aLayout), iInterface(aInterface), iExcluded(aExcluded), iLayoutInterface(0), iOpt(aOpt)
+	{
+	}
+
+LayCdlCheck::~LayCdlCheck()
+	{
+	delete iLayoutInterface;
+	}
+
+void LayCdlCheck::Process()
+	{
+	delete iLayoutInterface;
+	iLayoutInterface = 0;
+
+	auto_ptr<CCdlTkInterface> iface(LayoutToCdl::LayoutToInterface(iLayout));
+	iLayoutInterface = iface.get();
+	iface.release();
+
+	vector<string> good;
+	vector<string> onlyLay;
+	vector<string> onlyCdl;
+	vector<string> paramMismatch;
+
+	Compare(good, onlyLay, onlyCdl, paramMismatch);
+
+	if (HasOpt('g'))
+		Report("Good API", good);
+	if (HasOpt('l'))
+		Report("API only in lay file", onlyLay);
+	if (HasOpt('c'))
+		Report("API only in CDL file", onlyCdl);
+	if (HasOpt('m'))
+		Report("API with mismatched interface", paramMismatch);
+	}
+
+void LayCdlCheck::Compare(vector<string>& aGood, vector<string>& aOnlyLay, vector<string>& aOnlyCdl, vector<string>& aParamMismatch)
+	{
+	CCdlTkApiList& layApi = iLayoutInterface->ApiList();
+	CCdlTkApiList& cdlApi = iInterface.ApiList();
+	CCdlTkApiList& xApi = iExcluded.ApiList();
+	for (CCdlTkApiList::iterator pLay = layApi.begin(); pLay != layApi.end(); ++pLay)
+		{
+		const string& name = (*pLay)->Name();
+		CCdlTkApi* xCdl = xApi.Find(name);
+		if (xCdl && (*xCdl) == (**pLay))
+			continue;
+
+		string fullName = (*pLay)->ReturnType() + " " + name + (*pLay)->ParamsTypeAndNameList() + ";";
+		CCdlTkApi* cdl = cdlApi.Find(name);
+		if (cdl)
+			{
+			if (*cdl == **pLay)
+				{
+				aGood.push_back(fullName);
+				}
+			else
+				{
+				aParamMismatch.push_back(fullName + " vs " + cdl->ParamsTypeAndNameList());
+				}
+			}
+		else
+			{
+			aOnlyLay.push_back(fullName);
+			}
+		}
+
+	for (CCdlTkApiList::iterator pCdl = cdlApi.begin(); pCdl != cdlApi.end(); ++pCdl)
+		{
+		const string& name = (*pCdl)->Name();
+		string fullName = (*pCdl)->ReturnType() + " " + name + (*pCdl)->ParamsTypeAndNameList();
+		CCdlTkApi* lay = layApi.Find(name);
+		if (!lay)
+			{
+			aOnlyCdl.push_back(fullName);
+			}
+		}
+	}
+
+void LayCdlCheck::Report(const string& aTitle, vector<string>& aApi)
+	{
+	cout << aTitle << endl;
+	for (vector<string>::iterator pApi = aApi.begin(); pApi != aApi.end(); ++pApi)
+		{
+		cout << *pApi << endl;
+		}
+	cout << endl;
+	}
+
+bool LayCdlCheck::HasOpt(char c)
+	{
+	return iOpt.find(c) != string::npos;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayPerfWriter.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "LayPerfWriter.h"
+#include "Lay2Cdl.h" // for static methods
+#include "Layout.h" // for constants
+#include "CodeGenConsts.h"
+
+#include <cdlcompilertoolkit/cdltkutil.h>
+
+#include <iostream>
+#include <sstream>
+#include <set>
+#include <fstream>
+#include <algorithm>
+
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+
+//
+// TLayPerfTableWriter
+//
+
+TLayPerfTableWriter::TLayPerfTableWriter(TLayoutTable& aTable, string& aInterfaceName, int aTableId) 
+	: 
+	iTable(aTable),
+	iInterfaceName(aInterfaceName),
+	iTableId(aTableId)
+	{
+	}
+
+TLayPerfTableWriter::~TLayPerfTableWriter()
+	{
+	}
+
+void TLayPerfTableWriter::Write(ostream& out)
+	{
+	if (IsWindowTable())
+		{
+		WriteWindowTable(out);
+		}
+	else if (IsTextTable())
+		{
+		WriteTextTable(out);
+		}
+	else
+		{
+		cout << "Unknown " << "Table " << iTable.Name() << endl;
+		}
+	}
+
+bool TLayPerfTableWriter::IsWindowTable()
+	{
+	return iTable.iType == TLayoutTable::EWindowTable;
+	}
+
+
+const string KTestAPITableFuntionSig = "\
+testLayout_$LAYOUT_$TABLEID()";
+
+string GenerateFunctionName(string aInterfaceName, int aTableId)
+	{
+	string tableNum = CdlTkUtil::IntToString(aTableId);
+
+	CdlTkUtil::CReplaceSet rep;
+	rep.Add("$LAYOUT", aInterfaceName);
+	rep.Add("$TABLEID", tableNum);
+	return CdlTkUtil::MultiReplace(rep, KTestAPITableFuntionSig);
+	}
+
+void TLayPerfTableWriter::WriteWindowTable(ostream& out)
+	{
+	out << "void " << GenerateFunctionName(iInterfaceName, iTableId) << endl;
+
+	out << "{" << endl; // start of function
+	out << "DECLARE_LOCAL_VARS_COUNTS" << endl;
+	out << "DECLARE_LOCAL_VARS_LIMITS" << endl;
+
+	out << "\n// Layout MACROs for LAF Table : ";
+	out << iTable.Name() << endl;
+
+	for (int i=0; i<iTable.size(); ++i)
+		{
+		WriteWindowLine(out, *iTable[i]);
+		}
+
+	out << endl;
+	out << "}\n" << endl; // end of function
+	}
+
+void TLayPerfTableWriter::WriteWindowLine(ostream& out, TLayoutLine& aLine)
+	{
+	string params;
+	string limits;
+
+	bool mirrored = aLine.iIsMirroredHorizontally;
+	const string* KParams = mirrored ? KWindowOutputOrderMirrored : KWindowOutputOrder;
+	int count = KWindowOutputOrderSize;
+
+	BuildGenericLine(aLine, KParams, count, params, limits);
+
+	out << limits << endl; 
+
+	out << "LAYOUT_TEST_WINDOW_LINE( "; // macro name
+	out << iInterfaceName << "::"; // namespace name
+	out << LayoutToCdl::LineApiName(aLine); // api name
+	out << "(";
+
+	out << params << " )";
+	out << " )" << endl; // this ends the macro call
+	}
+
+void TLayPerfTableWriter::BuildGenericLine(TLayoutLine& aLine, const string* aKParams, int aCount, string& aParams, string& aLimits)
+	{
+	vector<string> paramList;
+	bool mirrored = aLine.iIsMirroredHorizontally;
+
+	if (aLine.iNeedsP)
+		{
+		aParams += "aParent";
+		}
+
+	if (aLine.iNeedsIndex)
+		{
+		for (int i=0; i < aCount; i++)
+			{
+			const string& name = aKParams[i];
+			const TValues& defValues = aLine[name];
+			if (defValues.iNeedsIndex)
+				{
+				string paramName = CdlTkUtil::ToCpp(defValues.ParamName());
+				if (mirrored)
+					{
+					if (paramName == KParamNameL)
+						paramName = KParamNameR;
+					else if (paramName == KParamNameR)
+						paramName = KParamNameL;
+					}
+
+				if(find(paramList.begin(), paramList.end(), paramName) == paramList.end())
+					{
+					if(aParams.size() > 0)
+						aParams += ", ";
+					aParams += paramName;
+					paramList.push_back(paramName);
+
+					aLimits += paramName + "_Limit" + " = ";
+					aLimits += CdlTkUtil::IntToString(defValues.size() - 1) + "; "; // subtract one from the max value to give the upper limit
+					}
+				}
+			}
+		}
+	}
+
+void TLayPerfTableWriter::WriteCell(ostream& out, TValues& values)
+	{
+	if (values.size() > 1)
+		out << "{";
+	
+	for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+		{
+		if (pVal != values.begin())
+			out << ", ";
+		out << *pVal;
+		}
+
+	if (values.size() > 1)
+		out << "}";
+
+	if (values.iParam.length())
+		out << "[" << values.iParam << "]";
+	}
+
+
+bool TLayPerfTableWriter::IsTextTable()
+	{
+	return iTable.iType == TLayoutTable::ETextTable;
+	}
+
+void TLayPerfTableWriter::WriteTextTable(ostream& out)
+	{
+	out << "void " << GenerateFunctionName(iInterfaceName, iTableId) << endl;
+
+	out << "{" << endl; // start of function
+	out << "DECLARE_LOCAL_VARS_COUNTS" << endl;
+	out << "DECLARE_LOCAL_VARS_LIMITS" << endl;
+
+	out << "// Layout MACROs for LAF Table : ";
+	out << iTable.Name() << endl;
+
+	for (int i=0; i<iTable.size(); ++i)
+		{
+		WriteTextLine(out, *iTable[i]);
+		}
+
+	out << endl;
+	out << "}\n" << endl; // end of function
+	}
+
+void TLayPerfTableWriter::WriteTextLine(ostream& out, TLayoutLine& aLine)
+	{
+	string params;
+	string limits;
+
+	bool mirrored = aLine.iIsMirroredHorizontally;
+	const string* KParams = mirrored ? KTextOutputOrderMirrored : KTextOutputOrder;
+	int count = KTextOutputOrderSize;
+
+	BuildGenericLine(aLine, KParams, count, params, limits);
+
+	out << limits << endl; 
+
+	out << "LAYOUT_TEST_TEXT_LINE( "; // macro name
+	out << iInterfaceName << "::"; // namespace name
+	out << LayoutToCdl::LineApiName(aLine); // api name
+	out << "(";
+
+	out << params << " )";
+	out << " )" << endl; // this ends the macro call
+	}
+
+
+//
+// TLayPerfWriter
+//
+
+TLayPerfWriter::TLayPerfWriter(TLayout& aLayout, const std::string& aName)
+: TLayWriterBase(aLayout, aName)
+	{
+	}
+
+void TLayPerfWriter::Write(const std::string& aCdlName)
+	{
+	ofstream out(iName.c_str());
+
+	cout << "writing layout " << iName << endl;
+	string cdlFileName(CdlTkUtil::StripPath(aCdlName));
+	string ifName(LayoutToCdl::InterfaceName(cdlFileName));
+
+	out << "// function implementations: " << endl;
+	int tableId = 0;
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		TLayPerfTableWriter writer(**pTab, ifName, tableId++);
+		writer.Write(out);
+		}
+
+	out << "void testLayout_" << ifName << "()\n{" << endl;
+	tableId = 0;
+	for(;tableId < iLayout.size(); tableId++)
+		{
+		out << GenerateFunctionName(ifName, tableId) << ";" << endl;
+		}
+	out << "}\n" << endl;
+
+
+	out.close();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayScale.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayScale.h"
+#include "LayoutParse.h"
+#include "LayoutCompilerErr.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+#include "LayoutWriter.h"
+
+typedef LayoutProcessArgsErr<LayoutScale> LayoutScaleArgsErr;
+
+
+int LayoutScale::Process(const vector<string>& args)
+	{
+	if (args.size() != 8)
+		throw LayoutScaleArgsErr();
+
+	auto_ptr<TLayParseLayout> sourceLayout(TLayParseLayout::Parse(args[2]));
+	int sourceWidth = CdlTkUtil::ParseInt(args[3]);
+	int sourceHeight = CdlTkUtil::ParseInt(args[4]);
+
+	string destLayout = args[5];
+	int destWidth = CdlTkUtil::ParseInt(args[6]);
+	int destHeight = CdlTkUtil::ParseInt(args[7]);
+
+	LayoutScale scale(*sourceLayout, sourceWidth, sourceHeight, destLayout, destWidth, destHeight);
+	scale.Run();
+
+	return 0;
+	}
+
+void LayoutScale::ShowHelp(ostream& stream)
+	{
+	stream << "LayScale <sourceLayout> <sourceWidth> <sourceHeight> <destLayout> <destWidth> <destHeight>" << endl;
+	stream << "  This performs an arithmetic scaling on all dimensional values in a layout." << endl;
+	stream << "  This will not produce a pixel perfect scaling effect due to rounding errors," << endl;
+	stream << "  however it may be sufficient for prototyping and demonstration purposes." << endl;
+	}
+
+LayoutScale::LayoutScale(TLayout& aSourceLayout, int aSourceWidth, int aSourceHeight, const string& aDestLayoutName, int aDestWidth, int aDestHeight)
+:	iLayout(aSourceLayout),
+	iSourceWidth(aSourceWidth),
+	iSourceHeight(aSourceHeight),
+	iDestLayoutName(aDestLayoutName),
+	iDestWidth(aDestWidth),
+	iDestHeight(aDestHeight)
+	{
+	}
+
+void LayoutScale::Run()
+	{
+	RescaleLayout();
+	WriteLayout();
+	}
+
+const string KHoriz = "lrW";
+const string KVert = "tbBH";
+const string KFont = "Font";
+const string KScaledSuffix = "_Scaled";
+
+void LayoutScale::RescaleLayout()
+	{
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		TLayoutTable& table = **pTab;
+		for (TLayoutTable::iterator pLine = table.begin(); pLine != table.end(); ++pLine)
+			{
+			TLayoutLine& line = **pLine;
+			for (TLayoutLine::iterator pCell = line.begin(); pCell != line.end(); ++pCell)
+				{
+				const string& cellName = pCell->first;
+				TValues& values = pCell->second;
+                if ( cellName == KFont)
+                    {
+				    for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+					    {
+					    TagScaledToken(*pVal);
+					    }                   
+                    }
+                else
+                    {
+   				    TScale dir = EHoriz;
+				    if (KVert.find(cellName) != string::npos)
+				        dir = EVert;
+				    else if (KHoriz.find(cellName) == string::npos)
+				        continue;
+
+				    for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+					    {
+					    RescaleValue(*pVal, dir);
+					    }
+                    }
+				}
+			}
+		}
+	}
+
+void LayoutScale::RescaleValue(string& aVal, TScale aDir)
+	{
+	// find all numbers in this value and rescale them, copy non-numeric text directly.
+	string result;
+	string num;
+	int count = aVal.size();
+	for (int pos = 0; pos < count; pos++)
+		{
+		char c = aVal[pos];
+		if (CdlTkUtil::IsNumeric(c))
+			{
+			num += c;
+			}
+		else
+			{
+			result += RescaleNum(num, aDir);
+			num = "";
+			result += c;
+			}
+		}
+	result += RescaleNum(num, aDir);
+	aVal = result;
+	}
+
+void LayoutScale::TagScaledToken(string& aToken)
+	{
+	string result(aToken);
+	result += KScaledSuffix;
+	aToken = result;
+	}
+
+string LayoutScale::RescaleNum(string& aNum, TScale aDir)
+	{
+	if (aNum.empty())
+		return aNum;
+
+	int num = CdlTkUtil::ParseInt(aNum);
+	if (aDir == EHoriz)
+		num = Scale(num, iDestWidth, iSourceWidth);
+	else
+		num = Scale(num, iDestHeight, iSourceHeight);
+	return CdlTkUtil::IntToString(num);
+	}
+
+void LayoutScale::WriteLayout()
+	{
+	TLayoutWriter writer(iLayout, iDestLayoutName);
+	writer.Write("");
+	}
+
+int LayoutScale::Scale(int aNumber, int aNumerator, int aDenominator)
+	{
+	// round to nearest whole number, rounding up on .5
+	int num = (aNumber * aNumerator) / aDenominator;		// rounded down
+	int remainder = (aNumber * aNumerator) % aDenominator;	// remainder
+	
+	if ((remainder*2) >= aDenominator)
+		num++;				// round up if remainder >= half
+
+	return num;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Layout.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,703 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "Layout.h"
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+#include <set>
+#include <sstream>
+#include <iostream>
+
+// TValues
+
+TValues::TValues()
+: iLine(0), iName("Bad Value")
+	{
+	}
+
+TValues::TValues(TLayoutLine* aLine, string aName)
+: iLine(aLine), iName(aName), iNeedsIndex(0)
+	{
+	}
+
+bool TValues::operator==(const TValues& aOther) const
+	{
+	typedef const vector<string> TBase;
+	bool eq =
+		iName == aOther.iName &&
+		iParam == aOther.iParam &&
+		iNeedsP == aOther.iNeedsP &&
+		iNeedsIndex == aOther.iNeedsIndex &&
+		(*static_cast<TBase*>(this) == aOther);
+	return eq;
+	}
+
+void TValues::Merge(TValues& aValues)
+	{
+	clear();
+	insert(begin(), aValues.begin(), aValues.end());
+	}
+
+void TValues::Compile()
+	{
+	iNeedsP = false;
+	if (!TLayoutTable::IsValueColumn(iName))
+		return;
+
+	for (iterator it = begin(); it != end(); ++it)
+		{
+		bool back2IsAlphaNum = false;
+		bool back1IsAlphaNum = false;
+		bool back1IsP = false;
+		for (string::iterator pC = it->begin(); pC!=it->end(); ++pC)
+			{
+			bool IsAlphaNum = (
+				('A' <= *pC && *pC <= 'Z') || 
+				('a' <= *pC && *pC <= 'z') ||
+				('0' <= *pC && *pC <= '9') ||
+				*pC == '_');
+
+			if (!back2IsAlphaNum && back1IsP && !IsAlphaNum)
+				iNeedsP = true;
+
+			back1IsP = *pC == 'p';
+			back2IsAlphaNum = back1IsAlphaNum;
+			back1IsAlphaNum = IsAlphaNum;
+			}
+
+		if (!back2IsAlphaNum && back1IsP)
+			iNeedsP = true;
+		}
+	iNeedsIndex = (size() > 1);
+	}
+
+string TValues::ParamName() const
+	{
+	if (iParam.length())
+		return iParam;
+	else
+		return KParamNameBase + iName;
+	}
+
+string TValues::CppValue(const string& aValue)
+	{
+	if (aValue.size())
+		return aValue;
+	else
+		return "ELayoutEmpty";
+	}
+
+
+//  TLayoutLine
+
+TLayoutLine::TLayoutLine( TLayoutTable* aTable, int aId )
+:	iTable(aTable), 
+	iId(aId), 
+	iIsUnique(true), 
+	iIsMirroredHorizontally(false),
+	iIsMergedIdentical(false)
+	{}
+
+TLayoutLine::TLayoutLine(TLayoutTable* aTable, const TLayoutLine& aOther)
+	{
+	*this = aOther;
+	iTable = aTable;
+	for (iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		TValues& val = pVal->second;
+		val.iLine = this;
+		}
+	}
+
+#ifdef RD_SHOW_ALL_AKNLAYOUTCOMPILER_WARNINGS
+void TLayoutLine::WarnMergeMismatch(TLayoutLine& aLine)
+#else
+void TLayoutLine::WarnMergeMismatch(TLayoutLine& /* aLine */)
+#endif
+	{
+    // Merge mismatch warnings are not shown from old lay files.
+#ifdef RD_SHOW_ALL_AKNLAYOUTCOMPILER_WARNINGS
+	string name = Name();
+	if (name.empty())
+		name = TableName();
+	else
+		name = iTable->iName + " | " + name;
+	cerr << "WARNING merge mismatch: " << iTable->iTables->iName << " | " << name;
+	cerr << " vs " << aLine.iTable->iTables->iName << endl;
+#endif
+	}
+
+void TLayoutLine::Merge(TLayout::TMergeMode aMergeMode, TLayoutLine& aLine)
+	{
+	iIsMergedIdentical = (*this == aLine) && (aMergeMode == TLayout::KMergeModeVariant);
+	if (iIsMergedIdentical)
+		return;
+
+	bool similar = (Name() == aLine.Name());
+	iterator pVal;
+
+	if (similar && aMergeMode == TLayout::KMergeModeVariant && aLine.iTable->iTables->iCanBeMirror)
+		{
+		// need to check to see if the parametrisations are mirrored
+		// first check for P
+		bool lr_p = (find("l")->second.iNeedsP && aLine["r"].iNeedsP);
+		bool rl_p = (find("r")->second.iNeedsP && aLine["l"].iNeedsP);
+		
+		// check if they both params are valid
+		bool lr_both = (find("l")->second.iNeedsIndex && aLine["r"].iNeedsIndex);
+		bool rl_both = (find("r")->second.iNeedsIndex && aLine["l"].iNeedsIndex);
+
+		// check if params are the same
+		bool lr_same = (find("l")->second.iParam == aLine["r"].iParam);
+		bool rl_same = (find("r")->second.iParam == aLine["l"].iParam);
+
+		// only mirrored if both are valid and same
+		bool lr = lr_p || (lr_both && lr_same);
+		bool rl = rl_p || (rl_both && rl_same);
+
+		// if either or both are parametrised the same way, need to swap; doesn't matter if 
+		// both attribs have same param, as swapping it won't make any difference.
+		if(rl || lr)
+			{
+			iIsMirroredHorizontally = true;
+			}
+		}
+
+	if (similar)
+		{
+		for (pVal=begin(); pVal!=end(); ++pVal)
+			{
+			TValues& val = pVal->second;
+			string cell = pVal->first;
+			if (iIsMirroredHorizontally)
+				{
+				if (cell == "l")
+					cell = "r";
+				else if (cell == "r")
+					cell = "l";
+				}
+
+			TValues& other = aLine[cell];
+			if (val.size() != other.size() || 
+				val.iNeedsIndex != other.iNeedsIndex || 
+				val.iNeedsP != other.iNeedsP)
+				{
+				similar = false;
+				}
+			}
+		}
+
+	if (!similar)
+		WarnMergeMismatch(aLine);
+
+	switch(aMergeMode)
+		{
+	case TLayout::KMergeModeMerge:
+	case TLayout::KMergeModeUnion:
+		if (similar)
+			{
+			for (pVal=begin(); pVal!=end(); ++pVal)
+				pVal->second.Merge(aLine[pVal->first]);
+			}
+		else
+			{
+			clear();
+			copy(aLine.begin(), aLine.end(), inserter(*this, begin()));
+			for (pVal=begin(); pVal!=end(); ++pVal)
+				pVal->second.iLine = this;
+			}
+		break;
+	case TLayout::KMergeModeVariant:
+		clear();
+		copy(aLine.begin(), aLine.end(), inserter(*this, begin()));
+		for (pVal=begin(); pVal!=end(); ++pVal)
+			pVal->second.iLine = this;
+		break;
+		}
+	}
+
+bool TLayoutLine::operator==(const TLayoutLine& aOther) const
+	{
+	return (Name() == aOther.Name()) && ValuesEqual(aOther);
+	}
+
+bool TLayoutLine::ValuesEqual(const TLayoutLine& aOther) const
+	{
+	bool eq = true;
+	const_iterator pVal, pOther;
+	for (pVal = begin(), pOther = aOther.begin(); 
+		 eq && pVal != end() && pOther != aOther.end(); 
+		 ++pVal, ++pOther)
+		{
+		eq = (*pVal == *pOther);
+		}
+	eq = eq && pVal == end() && pOther == aOther.end();
+	return eq;
+	}
+
+string TLayoutLine::Name() const
+	{
+	if (find("Item") != end())
+		return find("Item")->second[0];
+	else
+		return "";
+	}
+
+string TLayoutLine::TableName() const
+	{
+	stringstream name;
+	name << iTable->Name() << "_Line_" << iId;
+	return name.str();
+	}
+
+void TLayoutLine::Compile()
+	{
+	iNeedsP = false;
+	iNeedsIndex = false;
+
+	for (iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		TValues& val = pVal->second;
+		val.Compile();
+
+		if (val.iNeedsP)
+			iNeedsP = true;
+		if (val.iNeedsIndex)
+			iNeedsIndex = true;
+		}
+	}
+
+bool TLayoutLine::MatchParams(const TLayoutLine& aLine) const
+	{
+	if (iNeedsP != aLine.iNeedsP)
+		return false;
+
+	for (const_iterator pVal = begin(), pOther = aLine.begin(); pVal != end(); ++pVal, ++pOther)
+		{
+		const TValues& val = pVal->second;
+		const TValues& other = pOther->second;
+		if (val.iNeedsIndex != other.iNeedsIndex || val.ParamName() != other.ParamName())
+			return false;
+		}
+
+	return true;
+	}
+
+
+//
+// TLayoutTable
+//
+
+
+
+TLayoutTable::TLayoutTable(TLayout* aTables)
+: iTables(aTables), iType(EUnknownTable), iParent(0), iFirstLineGlobalIndex(-1), iAppend(false), iNoSubTables(false)
+	{
+	}
+
+TLayoutTable::TLayoutTable(TLayout* aTables, const TLayoutTable& aOther)
+: iTables(aTables), iType(aOther.iType), iParent(0), 
+  iFirstLineGlobalIndex(aOther.iFirstLineGlobalIndex), 
+  iAppend(aOther.iAppend), iColumnNames(aOther.iColumnNames), iName(aOther.iName),
+  iParentName(aOther.iParentName), iNoSubTables(aOther.iNoSubTables)
+	{
+	for (const_iterator it = aOther.begin(); it != aOther.end(); ++it)
+		push_back(new TLayoutLine(this, **it));
+	}
+
+TLayoutTable::~TLayoutTable()
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		delete *it;
+	DestroySubTables();
+	}
+
+void TLayoutTable::Merge(TLayout::TMergeMode aMergeMode, TLayoutTable& aTable)
+	{
+	if (aTable.iAppend)
+		{
+		insert(end(), aTable.begin(), aTable.end());
+		aTable.clear();
+		for (iterator pLine = begin(); pLine != end(); ++pLine)
+			(*pLine)->iTable = this;
+		}
+	else
+		{
+		// merge lines
+		iterator pNew = aTable.begin();
+		switch(aMergeMode)
+			{
+			case TLayout::KMergeModeMerge:
+				{
+				if (size() == aTable.size())
+					{
+					for (iterator pLine = begin(); pLine != end(); ++pLine)
+						{
+						(*pLine)->Merge(aMergeMode, **pNew);
+						pNew++;
+						}
+					}
+				else
+					{
+					// move the other tables contents to here
+					iterator pLine;
+					for (pLine = begin(); pLine != end(); ++pLine)
+						delete *pLine;
+					clear();
+					insert(begin(), aTable.begin(), aTable.end());
+					aTable.clear();
+					for (pLine = begin(); pLine != end(); ++pLine)
+						(*pLine)->iTable = this;
+					}
+					break;
+				}
+			case TLayout::KMergeModeVariant:
+				{
+				iterator pLine;
+				// need to merge the matching lines but append the extra ones [LMB 11-10-2002]
+				for (pLine = begin(); pLine != end() && pNew != aTable.end(); ++pLine)
+					{
+					(*pLine)->Merge(aMergeMode, **pNew);
+					pNew++;
+					}
+				insert(end(), pNew, aTable.end());
+				aTable.clear();
+				for (pLine = begin(); pLine != end(); ++pLine)
+					(*pLine)->iTable = this;
+				break;
+				}
+			case TLayout::KMergeModeUnion:
+				{
+				int index = 0;
+				for (; pNew != aTable.end(); ++pNew)
+					{
+					bool found = false;
+					for (iterator pLine = begin()+index; pLine != end(); ++pLine)
+						{
+						if ((*pLine)->Name() == (*pNew)->Name())
+							{
+							(*pLine)->Merge(aMergeMode, **pNew);
+							found = true;
+							break;
+							}
+						}
+					if (found)
+						{
+						delete *pNew;
+						}
+					else
+						{
+						if ((*pNew)->Name().empty())
+							{
+							throw GeneralErr(Name() + " can't union merge unnamed line");
+							}
+						push_back(*pNew);
+						(*pNew)->iTable = this;
+						if ((*pNew)->iId != size())
+							iNoSubTables = true;
+						(*pNew)->iId = size();
+						}
+					if (index+1 < size())
+						index++;
+					}
+				aTable.clear();
+				}
+			}
+		}
+	}
+
+string TLayoutTable::Name()
+	{
+	return iName;
+	}
+
+TLayoutLine* TLayoutTable::FindLine(const string& aName)
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		if ((*it)->Name() == aName)
+			return *it;
+	return 0;
+	}
+
+void TLayoutTable::Compile()
+	{
+	if (iType == EUnknownTable && iColumnNames.size() && iColumnNames[0].size())
+		{
+		if (iColumnNames[0] == "Item")
+			iType = EWindowTable;
+		else
+			iType = ETextTable;
+		}
+
+	SetDefaultColumnNames();
+
+	iParent = iTables->FindLine(iParentName);
+
+	iNeedsIndex = false;
+	iNeedsP = false;
+	for (iterator it = begin(); it != end(); ++it)
+		{
+		(*it)->Compile();
+		if ((*it)->iNeedsIndex)
+			iNeedsIndex = true;
+		if ((*it)->iNeedsP)
+			iNeedsP = true;
+		}
+
+	BuildSubTables();
+	}
+
+void TLayoutTable::BuildSubTables()
+	{
+	DestroySubTables();
+
+	if (iNoSubTables)
+		return;
+
+	int count = size();
+	TLayoutSubTable* subTable = 0;
+	for (int i=0; i<count; i++)
+		{
+		TLayoutLine& line = *(*this)[i];
+		if (subTable)
+			{
+			TLayoutLine* firstLine = (*this)[(*subTable)[0]];
+			if (!firstLine->MatchParams(line))
+				{
+				if (subTable->size() > 1)
+					iSubTables.push_back(subTable);
+				else
+					delete subTable;
+				subTable = new TLayoutSubTable;
+				}
+			}
+		else
+			{
+			subTable = new TLayoutSubTable;
+			}
+		subTable->iIsMergedIdentical = subTable->iIsMergedIdentical && line.iIsMergedIdentical;
+		subTable->push_back(i);
+		}
+
+	if (subTable->size() > 1)
+		iSubTables.push_back(subTable);
+	else
+		delete subTable;
+
+/*
+	for (int i=0; i<count; i++)
+		{
+		bool inserted = false;
+		TLayoutLine& nextLine = *(*this)[i];
+		for (TLayoutSubTables::iterator it = iSubTables.begin(); it != iSubTables.end(); ++it)
+			{
+			TLayoutLine* line = (*this)[*((*it)->begin())];
+			if (line->MatchParams(*(*this)[i]))
+				{
+				TLayoutSubTable& subTab = **it;
+				subTab.push_back(i);
+				subTab.iIsMergedIdentical = subTab.iIsMergedIdentical && nextLine.iIsMergedIdentical;
+				inserted = true;
+				}
+			}
+
+		if (!inserted)
+			{
+			TLayoutSubTable* subTable = new TLayoutSubTable;
+			subTable->push_back(i);
+			subTable->iIsMergedIdentical = nextLine.iIsMergedIdentical;
+			iSubTables.push_back(subTable);
+			}
+		}
+
+	TLayoutSubTables::iterator it = iSubTables.begin();
+	while (it != iSubTables.end())
+		{
+		if ((*it)->size() == 1)
+			it = iSubTables.erase(it);
+		else
+			++it;
+		}
+*/
+	}
+
+void TLayoutTable::DestroySubTables()
+	{
+	for (TLayoutSubTables::iterator it = iSubTables.begin(); it != iSubTables.end(); ++it)
+		delete *it;
+	iSubTables.clear();
+	}
+
+const string KValueNames[] = { "Font", "C", "l", "r", "B", "W", "J", "t", "r", "b", "H" };
+const set<string> KValueNamesSet(KValueNames, ARRAY_END(KValueNames));
+
+bool TLayoutTable::IsValueColumn(string aName)
+	{
+	return KValueNamesSet.find(aName) != KValueNamesSet.end();
+	}
+
+const string KNumericNames[] = { "C", "l", "r", "B", "W", "t", "r", "b", "H" };
+const set<string> KNumericNamesSet(KNumericNames, ARRAY_END(KNumericNames));
+
+bool TLayoutTable::IsNumericColumn(string aName)
+	{
+	return KNumericNamesSet.find(aName) != KNumericNamesSet.end();
+	}
+
+const string KWindowColumnNames[] = {"Item", "C", "l", "t", "r", "b", "W", "H", "Remarks"};
+const string KTextColumnNames[] = {"Font", "C", "l", "r", "B", "W", "J", "Remarks"};
+
+void TLayoutTable::SetDefaultColumnNames()
+	{
+	iColumnNames.clear();
+	if (iType == EWindowTable)
+		{
+		iColumnNames.insert(iColumnNames.end(), KWindowColumnNames, ARRAY_END(KWindowColumnNames));
+		}
+	else
+		{
+		iColumnNames.insert(iColumnNames.end(), KTextColumnNames, ARRAY_END(KTextColumnNames));
+		}
+	}
+
+bool TLayoutTable::IsWorthATableIndex()
+	{
+	return iSubTables.size() != 0;
+	}
+
+
+TLayoutTable::TLayoutSubTable::TLayoutSubTable()
+: iIsMergedIdentical(true)
+	{
+	}
+
+//
+// TLayout
+//
+
+TLayout::TLayout()
+: iCanBeMirror(false)
+	{
+	}
+
+TLayout::TLayout(const TLayout& aOther)
+	{
+	*this = aOther;
+	}
+
+TLayout& TLayout::operator=(const TLayout& aOther)
+	{
+	if (this != &aOther)
+		{
+		iName = aOther.iName;
+		iCanBeMirror = aOther.iCanBeMirror;
+		for (const_iterator it = aOther.begin(); it != aOther.end(); ++it)
+			push_back(new TLayoutTable(this, **it));
+		Compile();
+		}
+	return *this;
+	}
+
+TLayout::~TLayout()
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		delete *it;
+	}
+
+void TLayout::Merge(TLayout::TMergeMode aMergeMode, TLayout& aLayout)
+	{
+	if (iName.empty())
+		iName = aLayout.iName;
+
+	for (iterator pNew = aLayout.begin(); pNew != aLayout.end();)
+		{
+		iterator pTab;
+		for (pTab = begin(); pTab != end(); ++pTab)
+			{
+			if ((*pTab)->Name() == (*pNew)->Name())
+				break;
+			}
+
+		if (pTab == end())
+			{
+			push_back(*pNew);
+			(*pNew)->iTables = this;
+			pNew = aLayout.erase(pNew);
+			}
+		else
+			{
+			(*pTab)->Merge(aMergeMode, **pNew);
+			++pNew;
+			}
+		}
+
+	Compile();
+	}
+
+TLayoutLine* TLayout::FindLine(const string& aName)
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		{
+		TLayoutLine* line = (*it)->FindLine(aName);
+		if (line)
+			return line;
+		}
+
+	return 0;
+	}
+
+void TLayout::Compile()
+	{
+	iterator pTab;
+	for (pTab = begin(); pTab != end(); ++pTab)
+		(*pTab)->Compile();
+
+	// set uniqueness for lines
+	multiset<string> names;
+	for (pTab = begin(); pTab != end(); ++pTab)
+		{
+		TLayoutTable& tab = **pTab;
+		for (TLayoutTable::iterator pLine = tab.begin(); pLine != tab.end(); ++pLine)
+			names.insert((*pLine)->Name());
+		}
+
+	for (pTab = begin(); pTab != end(); ++pTab)
+		{
+		TLayoutTable& tab = **pTab;
+		for (TLayoutTable::iterator pLine = tab.begin(); pLine != tab.end(); ++pLine)
+			{
+			TLayoutLine& line = **pLine;
+			const string& name = line.Name();
+			if (name[0] == 'q')
+				{
+				line.iIsUnique = false;
+				}
+			else 
+				{
+				line.iIsUnique = (names.count(name) == 1);
+				}
+			}
+		}
+
+	}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayoutCompilerErr.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+#include "LayoutCompilerErr.h"
+#include <iostream>
+#include <algorithm>
+#include <string>
+using namespace std;
+
+void NotFoundErr::Show(ostream& stream) const
+	{
+	stream << iName << " not found" << endl;
+	}
+
+void GeneralErr::Show(ostream& stream) const
+	{
+	stream << iMessage << endl;
+	}
+
+string StreamLoc(const istream& aStream, const string& msg, int before, int after)
+	{
+	string out;
+	istream stream(aStream.rdbuf());
+	int pos = stream.tellg();
+#ifdef __VC32__
+	int start = _MAX(0, pos-before);
+#else
+	int start = max(0, pos-before);
+#endif
+	stream.seekg(start);
+	bool record = (start==0);
+	for (int i=0; i<(pos-start)+after; i++)
+		{
+		char ch = stream.get();
+		if (record)
+			out.append(1,ch);
+		if (ch == '\n' || ch == '\r')
+			record = true;
+		if (start+i == pos)
+			out.append(msg);
+		}
+	return out;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayoutConfig.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,251 @@
+/*
+* 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 "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:
+*
+*/
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayoutConfig.h"
+#include "LayoutCompilerErr.h"
+#include <fstream>
+#include <iostream>
+
+using namespace std;
+
+const string KBuildConfigFile("\\epoc32\\include\\oem\\bldvariant.hrh");
+const string KLayoutMacroStart("__LAYOUT");
+
+typedef LayoutProcessArgsErr<LayoutConfig> LayoutConfigArgsErr;
+
+
+LayoutConfig::Size::Size()
+: iWidth(0), iHeight(0)
+	{
+	}
+
+LayoutConfig::Size::TOrientation LayoutConfig::Size::Orientation() const
+	{
+	if (iWidth < iHeight)
+		return EPortrait;
+	else if (iWidth == iHeight)
+		return ESquare;
+	else
+		return ELandscape;
+	}
+
+bool LayoutConfig::Size::operator>(const Size& aRhs) const
+	{
+	if (iWidth == aRhs.iWidth)
+		return iHeight > aRhs.iHeight;
+	else
+		return iWidth > aRhs.iWidth;
+	}
+
+
+int LayoutConfig::Process(const vector<string>& args)
+	{
+	if (args.size() < 3)
+		throw LayoutConfigArgsErr();
+
+	string mode = CdlTkUtil::ToLower(args[2]);
+
+	auto_ptr<LayoutConfig> config(0);
+
+	if (mode == "wsini")
+		config = auto_ptr<LayoutConfig>(new WsiniConfig);
+	else
+		throw LayoutConfigArgsErr();
+
+	config->ParseArgs(args);
+	return config->Process();
+	}
+
+void LayoutConfig::ParseArgs(const vector<string>& args)
+	{
+	int argsSize = args.size();
+	int nextArg = 3;
+	while (nextArg < argsSize && args[nextArg][0] == '-')
+		{
+		ParseOpt(CdlTkUtil::ToLower(args[nextArg]));
+		nextArg++;
+		}
+
+	if (nextArg == argsSize)
+		throw LayoutConfigArgsErr();
+
+	iTargetFileName = args[nextArg];
+	nextArg++;
+
+	if (nextArg < argsSize)
+		iBaseFileName = args[nextArg];
+	}
+
+void LayoutConfig::ParseOpt(const std::string& opt)
+	{
+	if (opt.size() < 2)
+		throw LayoutConfigArgsErr();
+
+	switch (opt[1])
+		{
+		case 't':
+			if (opt == "-tplatform")
+				iTarget = EPlatform;
+			else if (opt == "-tproduct")
+				iTarget = EProduct;
+			else
+				throw LayoutConfigArgsErr();
+			break;
+		case 'l':
+			if (opt == "-llegacy")
+				iLegacyMode = ELegacyMode;
+			else if (opt == "-lnolegacy")
+				iLegacyMode = ENoLegacyMode;
+			else
+				throw LayoutConfigArgsErr();
+			break;
+		default:
+			throw LayoutConfigArgsErr();
+			break;
+		}
+	}
+
+void LayoutConfig::ShowHelp(ostream& stream)
+	{
+	stream << "Config <configMode> [-t<target>] [-l<legacyMode>] <targetFile> [<baseFile>]" << endl;
+	stream << "  <configMode> is one of wsini, epocini, aknlayout2" << endl;
+	stream << "  <target> is one of platform, product (default is platform)" << endl;
+	stream << "  <legacyMode> is one of legacy, nolegacy (default is legacy)" << endl;
+	stream << "  <targetFile> is the file to be written to" << endl;
+	stream << "  <baseFile> is a file containing the template for the target file" << endl;
+	}
+
+LayoutConfig::LayoutConfig()
+: iTarget(EPlatform), iLegacyMode(ELegacyMode)
+	{
+	LoadAllSizes();
+	LoadConfiguredSizes();
+	}
+
+LayoutConfig::~LayoutConfig()
+	{
+	}
+
+const LayoutConfig::Sizes& LayoutConfig::AllSizes() const
+	{
+	return iAll;
+	}
+
+const LayoutConfig::Sizes& LayoutConfig::ConfiguredSizes() const
+	{
+	return iConf;
+	}
+
+const LayoutConfig::Sizes& LayoutConfig::SizesForTarget() const
+	{
+	if (iTarget == EPlatform)
+		return iAll;
+	else
+		return iConf;
+	}
+
+void LayoutConfig::LoadAllSizes()
+	{
+	ifstream bldCfg;
+	OpenBldCfg(bldCfg);
+
+	string line;
+	while (!bldCfg.eof())
+		{
+		getline(bldCfg, line);
+		Size s;
+		if (ParseSize(line, s))
+			{
+			iAll.insert(s);
+			if (line.find("#define") == 0)
+				iConf.insert(s);
+			}
+		}
+	}
+
+void LayoutConfig::LoadConfiguredSizes()
+	{
+	// done crudely as part of the LoadAllSizes() function currently
+	}
+
+void LayoutConfig::OpenBldCfg(ifstream& aBldCfg)
+	{
+	aBldCfg.open(KBuildConfigFile.c_str());
+	if (!aBldCfg.is_open())
+		throw NotFoundErr(KBuildConfigFile);
+	}
+
+bool LayoutConfig::ParseSize(const std::string& aLine, Size& aSize) const
+	{
+	int pos = aLine.find(KLayoutMacroStart);
+	if (pos == string::npos)
+		return false;
+
+	pos += KLayoutMacroStart.size();
+	pos = aLine.find_first_not_of('_', pos);
+	if (pos == string::npos)
+		return false;
+
+	aSize.iWidth = CdlTkUtil::ParseInt(aLine.substr(pos));
+
+	pos = aLine.find('_', pos);
+	if (pos == string::npos)
+		return false;
+	pos = aLine.find_first_not_of('_', pos);
+	if (pos == string::npos)
+		return false;
+
+	aSize.iHeight = CdlTkUtil::ParseInt(aLine.substr(pos));
+	
+	return (aSize.iWidth != 0 && aSize.iHeight != 0);
+	}
+
+/*
+int LayoutConfig::TestLayoutConfig()
+	{
+	LayoutConfig l;
+
+	cout << "All:" << endl;
+	for (Sizes::iterator pAll = l.iAll.begin(); pAll != l.iAll.end(); ++pAll)
+		{
+		Size& s = *pAll;
+		cout << s.iWidth << " x " << s.iHeight << endl;
+		}
+	cout << "Conf:" << endl;
+	for (Sizes::iterator pConf = l.iConf.begin(); pConf != l.iConf.end(); ++pConf)
+		{
+		Size& s = *pConf;
+		cout << s.iWidth << " x " << s.iHeight << endl;
+		}
+	return 0;
+	}
+*/
+
+
+int WsiniConfig::Process()
+	{
+	const Sizes& s = SizesForTarget();
+// need a lot more info to make a sensible descision here
+// eg what is the prefered size and orientation? How should legacy mode be
+// handled, etc.
+// also, what should we do with multiple screens?????
+// neeeds a lot more thought.
+	return 0;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayoutPack.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "LayoutPack.h"
+#include "ZoomLevelNames.h"
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include "AknLayoutConsts.h"
+
+#include <sstream>
+#include <iostream>
+
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<LayoutPackage> LayoutPackageArgsErr;
+
+const string KLayoutPackCdlFile = "LayoutPack.cdl";
+
+int LayoutPackage::Process(vector<string>& args)
+	{
+	if (args.size() < 7)
+		throw LayoutPackageArgsErr();
+	
+	CZoomLevelNames zoomLevelNames;
+	zoomLevelNames.ProcessOptions(args);
+
+	string styleName;
+	string deliveryTypeName;
+    string priority;
+    string appUid;
+
+    ProcessOptionalStringArg(args, string("-s"), styleName);
+    ProcessOptionalStringArg(args, string("-d"), deliveryTypeName);
+    ProcessOptionalStringArg(args, string("-p"), priority);
+    ProcessOptionalStringArg(args, string("-a"), appUid);
+
+	string& name = args[2];
+	string& w = args[3];
+	string& h = args[4];
+	string& id = args[5];
+
+	for(CZoomLevelNames::iterator pZoomName = zoomLevelNames.begin(); pZoomName != zoomLevelNames.end(); ++pZoomName)
+		Process(name, w, h, id, styleName, deliveryTypeName, priority, appUid, args.begin() + 6, args.end(), pZoomName->second);
+
+	return 0;
+	}
+
+void LayoutPackage::ShowHelp(ostream& stream)
+	{
+	stream << "LayPkg [-z<zoomList>] [-s<screenStyleName>] [-d<deliverytype> -p<priority> [-a<appUid>]] <packageName> <width> <height> <layoutId> <instances>+" << endl;
+	stream << "  Creates CDL package according to Layout.cdl containing:" << endl;
+	stream << "    The name of the package." << endl;
+	stream << "    The size of screen that it applies to." << endl;
+	stream << "    The layout variant it is used for." << endl;
+	stream << "    The contents of the package." << endl;
+	stream << "  If -z<zoomList> is specified, then instances for zoom factors" << endl;
+	stream << "    (in the form \"n,string\") appearing in the file <zoomList> will be generated, " << endl;
+	stream << "    by replacing the keyword $ZOOM in the package definitions." << endl;
+	stream << "  If -s<screenStyleName> is specified, then instances for the appropriate" << endl;
+	stream << "    screen style as found in WSINI.INI will be generated." << endl;
+	stream << "  If -d<deliveryType> is specified then the delivery type will be appended to" << endl;
+	stream << "    the layout XML directory name." << endl;
+	stream << "  If -p<priority> is specified then the pack will be loaded in priority order compared to " << endl;
+	stream << "    instances of the same interface in all other packs, otherwise defaults to zero." << endl;
+	stream << "  If -a<appUid> is specified then the layout pack will only be loaded for an application" << endl;
+	stream << "    with a matching Secure UID, defaults to zero which means that the pack will be loaded" << endl;
+	stream << "    for any application ." << endl;
+	}
+
+void LayoutPackage::Process(
+	const string& aName, 
+	const string& aWidth, 
+	const string& aHeight, 
+	const string& aId, 
+	const string& aStyleName,
+    const string& aDeliveryTypeName,
+    const string& aPriority,
+    const string& aAppUid,
+	vector<string>::const_iterator aBegin, 
+	vector<string>::const_iterator aEnd, 
+	const string& aZoomName)
+	{
+	CCdlTkCdlFileParser parser(KDirDomainSysHeader+KLayoutPackCdlFile);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+	CCdlTkPackage pkg(*iface);
+	pkg.TemplateAllImplementations();
+
+	string zoomName = CdlTkUtil::Replace("$ZOOM", aZoomName, aName);
+	string zoomIdName = "EAknUiZoom" + aZoomName;
+	string styleHash = Hash(aStyleName);
+    string priority = CdlTkUtil::IntToString(CdlTkUtil::ParseInt(aPriority));
+    string appUid = CdlTkUtil::IntToHexString(CdlTkUtil::ParseInt(aAppUid));
+
+	pkg.SetName(zoomName);
+
+	Implement(pkg, "name", "\"\"", string("\"")+zoomName+"\"");
+	Implement(pkg, "size", "?width", aWidth);
+	Implement(pkg, "size", "?height", aHeight);
+	Implement(pkg, "id", "?value", aId);
+	Implement(pkg, "zoom", "?value", zoomIdName);
+	Implement(pkg, "styleHash", "?value", styleHash, string("	// screen style ") + aStyleName);
+	Implement(pkg, "priority", "?value", priority);
+	Implement(pkg, "appUid", "?value", appUid);
+
+	cout << zoomName << endl;
+
+	for (; aBegin != aEnd; ++aBegin)
+		{
+		const string& arg = *aBegin;
+		if (arg.size()>=2 && arg.substr(0,2)=="-x")
+			{
+			if (++aBegin == aEnd)
+				throw LayoutPackageArgsErr();
+			string dir = *aBegin;
+			
+			dir = CdlTkUtil::Replace("\\", "/", dir);
+			if (*dir.rbegin() != '/')
+				dir += "/";
+
+			if (++aBegin == aEnd)
+				throw LayoutPackageArgsErr();
+			const string& dll = *aBegin;
+
+			if (++aBegin == aEnd)
+				throw LayoutPackageArgsErr();
+			const string& inst = *aBegin;
+
+			string zoomContent = CdlTkUtil::Replace("$ZOOM", aZoomName, inst);
+			pkg.AddExternalContent(zoomContent, dir, dll);
+			}
+		else
+			{
+			string zoomContent = CdlTkUtil::Replace("$ZOOM", aZoomName, arg);
+			pkg.AddLocalContent(zoomContent);
+			cout << zoomContent << endl;
+			}
+		}
+
+	CCdlTkWriteInstance writer(pkg);
+	writer.Process();
+	}
+
+void LayoutPackage::Implement(
+	CCdlTkPackage& aPkg, 
+	const string& aApi, 
+	const string& aTarget, 
+	const string& aReplace,
+	const string& aComment)
+	{
+	CCdlTkImplementation* impl = aPkg.Impl().Find(aApi);
+	if (!impl)
+		throw NotFoundErr(aApi + " in LayoutPack.cdl");
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add(aTarget, aReplace);
+	implSet.Add("	//TODO: Initialise this data.", aComment);
+	impl->SetDefinition(CdlTkUtil::MultiReplace(implSet, impl->Definition()));
+	}
+
+void LayoutPackage::ProcessOptionalStringArg(vector<string>& args, const string& aOption, string& aArg)
+	{
+	for (vector<string>::iterator pArg = args.begin(); pArg != args.end(); ++pArg)
+		{
+		string& arg = *pArg;
+		if (arg.size() >= 2 && arg.substr(0,2) == aOption)
+			{
+			aArg = arg.substr(2);
+			args.erase(pArg);
+			return;
+			}
+		}
+	}
+
+string LayoutPackage::Hash(const string& aString)
+	{
+	int hash = 0;
+	for (string::const_iterator pChar = aString.begin(); pChar != aString.end(); ++pChar)
+		{
+		hash *= KAknLayoutScreenStyleNameHashMult;
+		hash += *pChar;
+		}
+	return CdlTkUtil::IntToHexString(hash);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayoutParse.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,300 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+#include "LayoutParse.h"
+#include <sstream>
+#include <fstream>
+#include <algorithm>
+#include <iostream> // !!! for debug output only
+
+extern string whiteSpace;
+
+void SkipWhitespace(istream& aIn)
+	{
+	char ch;
+
+	while (!aIn.eof())
+		{
+		ch = aIn.get();
+		if (whiteSpace.find(ch) == string::npos)
+			{
+			aIn.putback(ch);
+			break;
+			}
+		}
+	}
+
+void TrimEnd(string& aString)
+	{
+	int len = aString.length();
+	while (whiteSpace.find(aString[len-1]) != string::npos)
+		len--;
+	aString = aString.substr(0, len);
+	}
+
+string NextToken(istream& aIn, const string& aTerminate)
+	{
+	SkipWhitespace(aIn);
+
+	string ret;
+	char ch;
+
+	while (!aIn.eof())
+		{
+		ch = aIn.get();
+		if (aTerminate.find(ch) != string::npos)
+			{
+			if (ret.length())
+				aIn.putback(ch);
+			else
+				ret += (ch);
+			break;
+			}
+		ret += ch;
+		}
+
+	TrimEnd(ret);
+
+	return ret;
+	}
+
+void FindAndSkip(istream& aIn, const string& aString)
+	{
+	string tok = NextToken(aIn, aString);
+	if (aString.find(tok) == string::npos)
+		throw LayParseErr(aIn, tok, "not found");
+	}
+
+
+TLayParseValues::TLayParseValues(TLayoutLine* aLine, string aName)
+: TValues(aLine, aName)
+	{
+	}
+
+void TLayParseValues::Parse(istream& aIn)
+	{
+	string tok = NextToken(aIn, ",{}");
+	if (tok == "," || tok == "}")
+		{
+		aIn.putback(tok[0]);
+		push_back("");
+		}
+	else if (tok == "{")
+		{
+		do	{
+			TLayParseValues v(iLine, iName);
+			v.Parse(aIn);
+			insert(end(), v.begin(), v.end());
+			tok = NextToken(aIn, ",}");
+			} while (tok != "}");
+
+		tok = NextToken(aIn, ",}[");
+		if (tok == "[")
+			{
+			tok = NextToken(aIn, "]");
+			if (tok != "]")
+				{
+				iParam = tok;
+				FindAndSkip(aIn, "]");
+				}
+			}
+		else if (tok == "," || tok == "}")
+			{
+			aIn.putback(tok[0]);
+			}
+		else
+			{
+			throw LayParseErr(aIn, tok, "expected '[' ',' or '}'");
+			}
+		}
+	else
+		{
+		push_back(tok);
+		}
+	}
+
+
+//
+//  TLayParseLayoutLine
+//
+
+TLayParseLayoutLine::TLayParseLayoutLine(TLayoutTable* aTable, int aId)
+: TLayoutLine(aTable, aId)
+	{
+	}
+
+void TLayParseLayoutLine::Parse(istream& aIn)
+	{
+	FindAndSkip(aIn, "{");
+
+	string tok;
+
+	for (vector<string>::iterator pCol = iTable->iColumnNames.begin();
+		 pCol != iTable->iColumnNames.end();
+		 ++pCol)
+		{
+		TLayParseValues values(this, *pCol);
+		values.Parse(aIn);
+		insert(make_pair(*pCol, values));
+		tok = NextToken(aIn, ",}");
+		}
+
+	if (tok != "}")
+		throw LayParseErr(aIn, tok, "expected }");
+	}
+
+
+
+// TLayParseLayoutTable
+
+
+TLayParseLayoutTable::TLayParseLayoutTable(TLayout* aTables)
+: TLayoutTable(aTables)
+	{
+	}
+
+void TLayParseLayoutTable::Parse(istream& aIn)
+	{
+	string tok = NextToken(aIn, ":{}");
+	if (string(":{}").find(tok) != string::npos)
+		throw LayParseErr(aIn, tok, "expected table name");
+	iName = tok;
+
+	tok = NextToken(aIn, ":{");
+	if (string(":{").find(tok) == string::npos)
+		throw LayParseErr(aIn, tok, "expected ':' or '{'");
+
+	if (tok == ":")
+		{
+		iParentName = NextToken(aIn, "{");
+		FindAndSkip(aIn, "{");
+		}
+
+	tok = NextToken(aIn, "{+");
+	if (string("{+").find(tok) == string::npos)
+		throw LayParseErr(aIn, tok, "expected '+' or '{'");
+	else if (tok == "+")
+		iAppend = true;
+	else
+		aIn.putback(tok[0]);
+
+	int id = 0;
+	do  {
+		TLayParseLayoutLine* line = new TLayParseLayoutLine(this, ++id);
+		push_back(line);
+		line->Parse(aIn);
+		tok = NextToken(aIn, ",}");
+		if (string(",}").find(tok) == string::npos)
+			throw LayParseErr(aIn, tok, "expected ',' or '}'");
+		} while (tok != "}");
+	}
+
+
+
+void TLayParseLayout::Parse(istream& aIn)
+	{
+	while (!aIn.eof())
+		{
+		string tok = NextToken(aIn, whiteSpace);
+		if (tok == "WindowTable" || tok == "TextTable")
+			{
+			TLayParseLayoutTable* tab = new TLayParseLayoutTable(this);
+			push_back(tab);
+			tab->iType = (tok == "WindowTable" ? TLayoutTable::EWindowTable : TLayoutTable::ETextTable);
+			tab->SetDefaultColumnNames();
+			tab->Parse(aIn);
+			}
+		else if (tok.length()==0 && aIn.eof())
+			{
+			// white space at end of file
+			break;
+			}
+		else
+			{
+			throw LayParseErr(aIn, tok, "expected a Table");
+			}
+		}
+	Compile();
+	}
+
+auto_ptr<TLayParseLayout> TLayParseLayout::Parse(const string& aLayName)
+	{
+	string layName = aLayName;
+
+	auto_ptr<TLayParseLayout> layout(new TLayParseLayout);
+	if (layName.size() >= 2 && layName.substr(0,2) == "-m")
+		{
+		layName = layName.substr(2);
+		layout->iCanBeMirror = true;
+		}
+	layout->iName = layName;
+
+	int pos=0;
+	bool first = true;
+	while (pos != string::npos)
+		{
+		int next = layName.find('+', pos);
+		string name;
+		if (next == string::npos)
+			{
+			name = layName.substr(pos);
+			pos = next;
+			}
+		else
+			{
+			name = layName.substr(pos, next-pos);
+			pos = layName.find_first_not_of('+', next);
+			}
+
+		ifstream in(name.c_str());
+		if (!in.is_open())
+			throw NotFoundErr(name);
+		cout << "reading layout " << name << endl;
+
+		if (first)
+			{
+			layout->Parse(in);
+			}
+		else
+			{
+			TLayParseLayout nextLay;
+			nextLay.Parse(in);
+			layout->Merge(TLayout::KMergeModeUnion, nextLay);
+			}
+
+		first = false;
+		in.close();
+		}
+	return layout;
+	}
+
+
+
+LayParseErr::LayParseErr(istream& aIn, const string& aTok, const string& aMsg)
+: iLoc(StreamLoc(aIn,"<<Near Here>>", 100, 100)), iTok(aTok), iMsg(aMsg) 
+	{
+	}
+
+void LayParseErr::Show(ostream& aOut) const
+	{
+	aOut << "ERROR : \"" << iTok << "\" " << iMsg << endl << iLoc << endl;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/LayoutWriter.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "LayoutWriter.h"
+#include <iostream>
+#include <sstream>
+#include <set>
+#include <fstream>
+using namespace std;
+
+
+TLayoutTableWriter::TLayoutTableWriter(TLayoutTable& aTable) : iTable(aTable)
+	{
+	}
+
+TLayoutTableWriter::~TLayoutTableWriter()
+	{
+	}
+
+void TLayoutTableWriter::Write(ostream& out)
+	{
+	if (IsWindowTable())
+		{
+		WriteWindowTable(out);
+		}
+	else if (IsTextTable())
+		{
+		WriteTextTable(out);
+		}
+	else
+		{
+		cout << "Unknown " << "Table " << iTable.Name() << endl;
+		}
+	}
+
+bool TLayoutTableWriter::IsWindowTable()
+	{
+	return iTable.iType == TLayoutTable::EWindowTable;
+	}
+
+
+void TLayoutTableWriter::WriteWindowTable(ostream& out)
+	{
+	out << "WindowTable " << iTable.Name();
+	if (iTable.iParentName.size())
+		out << " : " << iTable.iParentName;
+	out << endl;
+	out << "\t{" << endl;
+
+	if (iTable.iAppend)
+		out << "\t+" << endl;
+	
+	for (int i=0; i<iTable.size(); ++i)
+		{
+		if (i>0)
+			out << "," << endl;
+		WriteWindowLine(out, *iTable[i]);
+		}
+
+	out << endl << "\t}" << endl;
+	out << endl;
+	}
+
+void TLayoutTableWriter::WriteWindowLine(ostream& out, TLayoutLine& line)
+	{
+	out << "\t\t{" << line.Name() << ", ";
+
+	for (int i=0; i<7; i++)
+		{
+		WriteCell(out, line[KWindowOutputOrder[i]]);
+		out << ", ";
+		}
+
+	out << line["Remarks"][0] << "}";
+	}
+
+void TLayoutTableWriter::WriteCell(ostream& out, TValues& values)
+	{
+	if (values.size() > 1)
+		out << "{";
+	
+	for (TValues::iterator pVal = values.begin(); pVal != values.end(); ++pVal)
+		{
+		if (pVal != values.begin())
+			out << ", ";
+		out << *pVal;
+		}
+
+	if (values.size() > 1)
+		out << "}";
+
+	if (values.iParam.length())
+		out << "[" << values.iParam << "]";
+	}
+
+
+bool TLayoutTableWriter::IsTextTable()
+	{
+	return iTable.iType == TLayoutTable::ETextTable;
+	}
+
+void TLayoutTableWriter::WriteTextTable(ostream& out)
+	{
+	out << "TextTable " << iTable.Name();
+	if (iTable.iParentName.size())
+		out << " : " << iTable.iParentName;
+	out << endl;
+	out << "\t{" << endl;
+
+	if (iTable.iAppend)
+		out << "\t+" << endl;
+	
+	for (int i=0; i<iTable.size(); ++i)
+		{
+		if (i>0)
+			out << "," << endl;
+		WriteTextLine(out, *iTable[i]);
+		}
+
+	out << endl << "\t}" << endl;
+	out << endl;
+	}
+
+void TLayoutTableWriter::WriteTextLine(ostream& out, TLayoutLine& line)
+	{
+	out << "\t\t{" << line["Font"][0] << ", ";
+
+	for (int i=0; i<6; i++)
+		{
+		WriteCell(out, line[KTextOutputOrder[i]]);
+		out << ", ";
+		}
+
+	out << line["Remarks"][0] << "}";
+	}
+
+
+TLayoutWriter::TLayoutWriter(TLayout& aLayout, const std::string& aName)
+: TLayWriterBase(aLayout, aName)
+	{
+	}
+
+void TLayoutWriter::Write(const std::string&)
+	{
+	cout << "writing layout " << iName << endl;
+	ofstream out(iName.c_str());
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		TLayoutTableWriter writer(**pTab);
+		writer.Write(out);
+		}
+	out.close();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLAttributes.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,113 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#include "MLAttributes.h"
+#include "MLAttributesParse.h"
+
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+//
+//  class TMLAttributeSet
+//
+TMLAttributeSet::TMLAttributeSet()
+	{
+
+	}
+
+TMLAttributeSet::TMLAttributeSet(TMLAttributes* aAttributes)
+	:
+	iAttributes(aAttributes)
+	{
+	
+	}
+
+TMLAttributeSet::~TMLAttributeSet()
+	{
+
+	}
+
+void TMLAttributeSet::Merge(TMLAttributeSet& aOther)
+	{
+
+	}
+
+void TMLAttributeSet::Compile()
+	{
+
+	}
+
+//
+//  class TMLAttributes
+//
+
+TMLAttributes::TMLAttributes()
+	{
+
+	}
+
+TMLAttributes::~TMLAttributes()
+	{
+	for(iterator pComponent = begin(); pComponent != end(); ++pComponent)
+		{
+		TMLAttributeSetComponent& component = pComponent->second;
+		for(TMLAttributeSetComponent::iterator pAttributeSet = component.begin(); pAttributeSet != component.end(); ++pAttributeSet)
+			{
+			TMLAttributeSet* nextSet = pAttributeSet->second;
+			delete nextSet;
+			}
+		}
+	}
+
+void TMLAttributes::Merge(TMLAttributes& aOther)
+	{
+	for(iterator pOtherComponent = aOther.begin(); pOtherComponent != aOther.end(); ++pOtherComponent)
+		{
+		int compId = pOtherComponent->first;
+		TMLAttributeSetComponent& otherComponent = pOtherComponent->second;
+		TMLAttributeSetComponent& thisComponent = (*this)[compId];
+		for(TMLAttributeSetComponent::iterator pOtherAttributeSet = otherComponent.begin(); pOtherAttributeSet != otherComponent.end(); ++pOtherAttributeSet)
+			{
+			string name = pOtherAttributeSet->first;
+			TMLAttributeSet* otherSet = pOtherAttributeSet->second;
+			TMLAttributeSetComponent::iterator foundThisSet = thisComponent.find(name);
+			if(foundThisSet == thisComponent.end() && otherSet)
+				{
+				TMLAttributeSet* otherSetCopy = new TMLAttributeSet(*otherSet);
+				thisComponent.insert(make_pair(name, otherSetCopy));
+				}
+			}
+		}
+	for(TMLAttributeNames::iterator nextOtherName = aOther.iNames.begin(); nextOtherName != aOther.iNames.end(); ++nextOtherName)
+		{
+		// we want the superset of all the names, 
+		// it doesn't matter if there are names that correspond to attributes that don't actually exist
+		// as it won't take up much memory and we won't look for them
+		int& nextThisNameValue = iNames[nextOtherName->first];
+		nextThisNameValue = nextOtherName->second;
+		}
+	}
+
+void TMLAttributes::Compile()
+	{
+
+	}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLAttributesParse.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,257 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning(disable: 4786 4250 4503 4541)
+
+
+#include "MLAttributesParse.h"
+#include "MLCompDataParse.h" // for converting zoom strings
+
+#include <akndef.hrh> // for logical font ids
+
+#include <sstream>
+#include <fstream>
+#include <algorithm>
+#include <iostream> // !!! for debug output only
+
+extern string whiteSpace;
+
+
+// const data
+//
+
+const string KAttributesParseRoot = "LayoutAttributes";
+const string KAttributesParseRootAttributeCreatedOn = "createdOn";
+
+const string KAttributesParseNodeAttributeSet = "attributeset";
+const string KAttributesParseNodeAttributeSetAttributeId = "compId";
+const string KAttributesParseNodeAttributeSetAttributeName = "name";
+
+const string KAttributesParseNodeAttribute = "attribute";
+const string KAttributesParseNodeAttributeAttributeId = "id";
+const string KAttributesParseNodeAttributeAttributeName = "name";
+
+const string KAttributesParseNodeCalc = "calc";
+const string KAttributesParseNodeCalcAttributeValue = "value";
+const string KAttributesParseNodeCalcAttributeZoom = "zoom";
+
+
+//
+// class TMLAttributeSetParse
+//
+TMLAttributeSetParse::TMLAttributeSetParse(TMLAttributes* aAttributes)
+	:
+	TMLAttributeSet(aAttributes),
+	iSaxZoomLevels(0)
+	{
+
+	}
+
+MSaxLayoutAttributesHandler* TMLAttributeSetParse::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	//	<attributeset compId="1" name="a0">
+	if (aElement == KAttributesParseNodeAttributeSet)	
+		{
+		iCompId = CdlTkUtil::ParseInt(aAttribs.getValue(KAttributesParseNodeAttributeSetAttributeId));
+		iName = aAttribs.getValue(KAttributesParseNodeAttributeSetAttributeName);
+		}
+	else if(aElement == KAttributesParseNodeAttribute)
+		{
+		HandleSaxAttribute(aAttribs);
+		}
+	else if(aElement == KAttributesParseNodeCalc)
+		{
+		HandleSaxCalc(aAttribs);
+		}
+	return this;
+	}
+
+void TMLAttributeSetParse::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KAttributesParseNodeAttribute)
+		{
+		insert(make_pair(iId, *iSaxZoomLevels));
+		delete iSaxZoomLevels;
+		iSaxZoomLevels = 0;
+		}
+	}
+
+void TMLAttributeSetParse::HandleSaxAttribute(const TAttribs& aAttribs)
+	{
+	delete iSaxZoomLevels;
+	iSaxZoomLevels = 0;
+	iSaxZoomLevels = new TMLAttributeZoomLevels;
+
+	//    <attribute id="8" name="style 1">
+	iId = CdlTkUtil::ParseInt(aAttribs.getValue(KAttributesParseNodeAttributeAttributeId));
+	string attributeName = CdlTkUtil::ToCpp(aAttribs.getValue(KAttributesParseNodeAttributeAttributeName));
+	iAttributes->iNames.insert(make_pair(attributeName, iId));
+	}
+
+void TMLAttributeSetParse::HandleSaxCalc(const TAttribs& aAttribs)
+	{
+	//      <calc value="32"/>
+	//      <calc value="28" zoom="-2 zoom"/>
+	//      <calc value="38" zoom="+2 zoom"/>
+	//      <calc value="30" zoom="-1 zoom"/>
+	//      <calc value="36" zoom="+1 zoom"/>
+
+	string zoomStr = aAttribs.getValue(KAttributesParseNodeCalcAttributeZoom);
+	int zoom = TMLCompDataParseValues::ConvertZoomStr(zoomStr);
+	if(zoom != EAknUiZoomAutomatic)
+		{
+		string& calc = (*iSaxZoomLevels)[zoom];
+		calc = aAttribs.getValue(KAttributesParseNodeCalcAttributeValue);
+		}
+	}
+
+int TMLAttributeSetParse::CompId() const 
+	{
+	return iCompId;
+	}
+
+string TMLAttributeSetParse::Name() const
+	{
+	return iName;
+	}
+
+
+//
+// class TMLAttributesParse
+//
+auto_ptr<TMLAttributesParse> TMLAttributesParse::Parse(const string& aLayName)
+	{
+	auto_ptr<TMLAttributesParse> layout(new TMLAttributesParse);
+	int pos=0;
+	string layName = aLayName;
+
+	if (layName.size() >= 2 && layName.substr(0,2) == "-m")
+		{
+		layName = layName.substr(2);
+		layout->iCanBeMirror = true;
+		}
+	layout->iName = layName;
+
+	// SAX parsing method
+	cout << "reading MLAttributes(SAX) " << layName << endl;
+	TLayoutAttributesSaxParser saxParser(layout.get());
+	saxParser.Parse(layName);
+
+	return layout;
+	}
+
+TMLAttributesParse::TMLAttributesParse()
+	:
+	iSaxAttributeSet(0)
+	{
+
+	}
+
+MSaxLayoutAttributesHandler* TMLAttributesParse::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if (aElement == KAttributesParseRoot)
+		{
+		// <LayoutAttributes 
+		//		createdOn="2005-05-20 00:55:40.185" 
+		//		LayoutToolVer="2005-05-12 04:10 PM" 
+		//		MasterId="0.6921563014440754">
+		iTimestamp = aAttribs.getValue(KAttributesParseRootAttributeCreatedOn);
+		return this;
+		}
+	else if (aElement == KAttributesParseNodeAttributeSet)
+		{
+		delete iSaxAttributeSet;
+		iSaxAttributeSet = 0;
+		iSaxAttributeSet = new TMLAttributeSetParse(this);
+		iSaxAttributeSet->HandleSax(aElement, aAttribs);
+		return iSaxAttributeSet;
+		}
+	else
+		return this;
+	}
+
+void TMLAttributesParse::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KAttributesParseNodeAttributeSet)
+		{
+		TMLAttributeSetComponent& component = (*this)[iSaxAttributeSet->CompId()];
+		component.insert(make_pair(iSaxAttributeSet->Name(), iSaxAttributeSet));
+		iSaxAttributeSet = 0;
+		}
+	}
+
+
+//
+// TLayoutAttributesSaxParser
+//
+
+TLayoutAttributesSaxParser::TLayoutAttributesSaxParser(MSaxLayoutAttributesHandler* aHandler)
+	{ 
+	iStack.push(aHandler);
+	}
+
+void TLayoutAttributesSaxParser::Parse(const std::string& aFileName)
+	{
+	SAX::basic_InputSource<std::string> is(aFileName);
+	SAX::XMLReader<std::string> parser;
+	parser.setContentHandler(*this);
+	parser.setErrorHandler(*this);
+	parser.parse(is);
+	}
+
+void TLayoutAttributesSaxParser::startElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                              const std::string& /*qName*/, const SAX::basic_Attributes<std::string>& atts)
+    {
+	MSaxLayoutAttributesHandler* handler = iStack.top();
+	if (!handler)
+		throw GeneralErr("SAX: No element handler");
+	MSaxLayoutAttributesHandler* next = handler->HandleSax(localName, atts);
+	iStack.push(next);
+    }
+
+void TLayoutAttributesSaxParser::endElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                            const std::string& /*qName*/)
+    {
+	iStack.pop();
+	MSaxLayoutAttributesHandler* handler = iStack.top();
+	if (handler)
+		handler->HandleSaxEnd(localName);
+    }
+
+
+void TLayoutAttributesSaxParser::warning(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TLayoutAttributesSaxParser::error(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TLayoutAttributesSaxParser::fatalError(const TException& aException)
+    {
+	cerr << aException.what();
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompCdl2InstO.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,2016 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated" warning	
+#pragma warning (disable:4503)
+
+#include "MLCompDataParse.h"
+#include "MLCompCdl2InstO.h"
+#include "ZoomLevelNames.h"
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "CppWriter.h"
+#include "MLCompData2Cdl.h"
+#include "LayCdl2InstO.h" // for common classes
+#include "MLAttributesParse.h"
+#include "MLAttributes.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+#include <akndef.hrh>
+
+#include <fstream>
+#include <algorithm>
+#include <iostream>
+#include <numeric> // accumulate
+
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+//
+// defines
+//
+
+#define AKNLAYOUT_DEFINE_BYTECODE(name,byte) const char name = char(byte);
+#include "AknLayoutByteCodes.h"
+
+typedef LayoutProcessArgsErr<MLCompDataCdlInstanceOpt> MLCompDataCdlInstanceOptArgsErr;
+
+
+//
+// constants
+//
+
+const string KDefinitionNotDefined("Layout not defined, this API must not be called for this instance");
+const string KDefinitionNotSet("Layout definition not found");
+extern string KMultiLine;
+const string KSpace = " ";
+const string KComma = ",";
+const string KTheWordBlank("blank");
+const string KParentRelativeMarker("Pp");
+const string KCellNameJustification("J");
+const string KCompDataFileNameSuffix("compData");
+const string KAttributesFileNameSuffix("attributes");
+
+// this is the addressable area for each instance, as the lookup table is 16bit
+const int KAddressableBytecodedData = 0xFFFF;
+
+/**
+*  SCompDataImplFunc
+*  This class represents a layout data decompression function local to a layout instance.
+*  These functions will call the corresponding DLL wide function for decompression.
+*/
+struct SCompDataImplFunc
+	{
+	enum TFuncType
+		{ 
+		EWindowLine, 
+		ETextLine,
+		ETableLimits,
+		EWindowTable, 
+		ETextTable,
+		ELineParamLimits,
+		ETableParamLimits,
+		EGenericComponentType,
+		EGenericParamLimits,
+		EGenericWindowComponent,
+		EGenericTextComponent
+		};
+	TFuncType iType;
+	CCdlTkApiParams iParams;
+	string iDefn;
+	string iPtrRef;
+
+	SCompDataImplFunc(TFuncType aType, string aDefn, string aPtrRef, CCdlTkApiParams& aParams)
+		: 
+		iType(aType), 
+		iDefn(aDefn), 
+		iPtrRef(aPtrRef),
+		iParams(aParams)
+		{
+			
+		}
+
+	SCompDataImplFunc(TFuncType aType, string aDefn, string aPtrRef)
+		: 
+		iType(aType), 
+		iDefn(aDefn), 
+		iPtrRef(aPtrRef)
+		{
+			
+		}
+
+	bool IsSimilar(TFuncType aType, CCdlTkApiParams& aParams)
+		{
+		if(iType != aType) 
+			return false;
+		int size = iParams.size();
+		if(size != aParams.size())
+			return false;
+		for(int ii = 0; ii < size; ii++)
+			{
+			CCdlTkApiParam& thisParam = iParams[ii];
+			CCdlTkApiParam& otherParam = aParams[ii];
+			if(thisParam.Name() != otherParam.Name())
+				return false;
+			if(thisParam.Type() != otherParam.Type())
+				return false;
+			// don't compare the default value, as we're not interested in that for the implementation.
+			}
+		return true;
+		}
+	};
+
+
+/**
+*  CAllCompDataFuncs
+*  This represents a collection of all the SCompDataImplFunc objects that a layout instance may need
+*/
+class CAllCompDataFuncs : public vector<SCompDataImplFunc>
+	{
+public:
+	CAllCompDataFuncs();
+
+private:
+	void AddFunc(SCompDataImplFunc::TFuncType aType, CCdlTkApiParams& aParams, const string& aReturn, const string& aFuncName, bool aAppendAbbreviation);
+	void AddParamsToFunc(CCdlTkApiParams& aParams, string& aDefn, string& aBody);
+	void AddParamToFunc(string aFiller, string aParamName, string& aDefn, string& aBody);
+	};
+
+
+
+/**
+*  gTheFuncs
+*  This is a collection of all SCompDataImplFunc objects that a layout instance needs, initialised
+*  so that there are up to four integer parameters per API type.
+*/
+CAllCompDataFuncs gTheFuncs;
+
+//
+// CAllCompDataFuncs
+//
+
+CAllCompDataFuncs::CAllCompDataFuncs()
+	{
+	// need to generate all combinations of parameters
+	vector<string> paramNames;
+	paramNames.push_back(KParamOptionIndex);
+	paramNames.push_back(KParamColIndex);
+	paramNames.push_back(KParamRowIndex);
+
+	// all cominations of option, row, and column are possible, in any order
+	typedef vector<int> Seq;
+	Seq pattern;
+	set< Seq > subPatterns;
+
+	// for each of the available positions, there could be any available value, or it could be empty
+	const int numPlaces = paramNames.size();
+	for(int jj = 0; jj < numPlaces; jj++)
+		pattern.push_back(jj);
+
+	// for each permutation, copy all the possible positions
+	// into a separate set, which hence will be filled with the unique permutations
+	do
+		{
+		int numMasks = (1 << numPlaces); // eg for 3 places there are 8 masks
+		for(int mask = 0; mask < numMasks; mask++)
+			{
+			Seq subPattern;
+			int bit = 0;
+			// count down the bits
+			for(int bitCount = mask; bitCount != 0; bitCount >>= 1)
+				{
+				if(mask & (1 << bit))
+					subPattern.push_back(pattern[bit]);
+				bit++;
+				}
+			subPatterns.insert(subPattern);
+			}
+		}
+	while(next_permutation(pattern.begin(), pattern.end()));
+
+	for(set< Seq >::iterator pPattern = subPatterns.begin(); pPattern != subPatterns.end(); ++pPattern)
+		{
+		CCdlTkApiParams params;
+		for(Seq::iterator pParam = pPattern->begin(); pParam != pPattern->end(); ++pParam)
+			{
+			int& param = (*pParam);
+			string name = paramNames[param];
+			params.push_back(CCdlTkApiParam(KTypeInt, name));
+			}
+		AddFunc(SCompDataImplFunc::EWindowLine, params, KTypeWindowComponentLayout, KFuncWindowLine, true);
+		AddFunc(SCompDataImplFunc::ETextLine, params, KTypeTextComponentLayout, KFuncTextLine, true);
+
+		params.insert(params.begin(), CCdlTkApiParam(KTypeInt, KParamLineIndex));
+		AddFunc(SCompDataImplFunc::EWindowTable, params, KTypeWindowComponentLayout, KFuncWindowTable, true);
+		AddFunc(SCompDataImplFunc::ETextTable, params, KTypeTextComponentLayout, KFuncTextTable, true);
+		}
+
+	for(int ii = 0; ii < 2; ii++)
+		{
+		CCdlTkApiParams params;
+		if(ii)
+			{
+			params.push_back(CCdlTkApiParam(KTypeInt, KParamOptionIndex));
+			}
+		AddFunc(SCompDataImplFunc::ELineParamLimits, params, KTypeLayoutScalableParameterLimits, KFuncParamLimits, true);
+		params.insert(params.begin(), CCdlTkApiParam(KTypeInt, KParamLineIndex));
+		AddFunc(SCompDataImplFunc::ETableParamLimits, params, KTypeLayoutScalableParameterLimits, KFuncParamLimitsTable, true);
+		}
+
+	SCompDataImplFunc limits(
+		SCompDataImplFunc::ETableLimits, 
+		KTypeLayoutScalableTableLimits + " Limits() { return AknLayoutScalableDecode::TableLimits(KDataLookup); }",
+		"&Limits");
+	push_back(limits);
+
+	// finally, the generic APIs
+	CCdlTkApiParams params;
+	params.push_back(CCdlTkApiParam(KTypeInt, KParamComponentId));
+	AddFunc(SCompDataImplFunc::EGenericComponentType, params, KTypeLayoutScalableComponentType, KFuncGetComponentTypeById, false);
+
+	// param limits needs the variety index
+	params.push_back(CCdlTkApiParam(KTypeInt, KParamOptionIndex));
+	AddFunc(SCompDataImplFunc::EGenericParamLimits, params, KTypeLayoutScalableParameterLimits, KFuncGetParamLimitsById, false);
+
+	// and getting the component by id requires all the params
+	params.push_back(CCdlTkApiParam(KTypeInt, KParamColIndex));
+	params.push_back(CCdlTkApiParam(KTypeInt, KParamRowIndex));
+	AddFunc(SCompDataImplFunc::EGenericWindowComponent, params, KTypeWindowComponentLayout, KFuncGetWindowComponentById, false);
+	AddFunc(SCompDataImplFunc::EGenericTextComponent, params, KTypeTextComponentLayout, KFuncGetTextComponentById, false);
+	}
+
+void CAllCompDataFuncs::AddFunc(SCompDataImplFunc::TFuncType aType, CCdlTkApiParams& aParams, const string& aReturn, const string& aFuncName, bool aAppendAbbreviation)
+	{
+	// create a function of this form:
+	//TAknWindowComponentLayout WindowTable$NUM$PARENT($PARAMS_TYPES_AND_NAMES)
+	//	{
+	//	return AknLayoutScalableDecode::WindowLine$NUM$PARENT(&KImplData, $PARAM_NAMES);
+	//  }
+	string funcName = aFuncName;
+	if(aAppendAbbreviation)
+		for(CCdlTkApiParams::iterator pParam = aParams.begin(); pParam != aParams.end(); ++pParam)
+			funcName += pParam->Name().substr(1, 1); // append the first character after the "a"
+
+	string defn = aReturn + " " + funcName + "(";
+	string body = string(") { return AknLayoutScalableDecode::") + funcName + "(&KImplData";
+	AddParamsToFunc(aParams, defn, body);
+	defn += body + "); }";
+
+	string ptrRef = string("&") + funcName;
+
+	SCompDataImplFunc func(aType, defn, ptrRef, aParams);
+	push_back(func);
+	}
+
+void CAllCompDataFuncs::AddParamsToFunc(CCdlTkApiParams& aParams, string& aDefn, string& aBody)
+	{
+	string filler = "";
+	for(CCdlTkApiParams::iterator pParam = aParams.begin(); pParam != aParams.end(); ++pParam)
+		{
+		AddParamToFunc(filler, pParam->Name(), aDefn, aBody);
+		filler = KComma + KSpace;
+		}
+	}
+
+void CAllCompDataFuncs::AddParamToFunc(string aFiller, string aParamName, string& aDefn, string& aBody)
+	{
+	aDefn += aFiller + string(KTypeInt) + KSpace + aParamName;
+	aBody += KComma + KSpace + aParamName;
+	}
+
+
+//
+// CMLCompDataInstOptImpl
+//
+
+class CMLCompDataInstOptImpl
+	{
+public:
+	CMLCompDataInstOptImpl(CCdlTkImplementation* aImpl);
+	virtual ~CMLCompDataInstOptImpl();
+public:
+	CCdlTkImplementation* iImpl;
+	int iByteCodeIndex;
+	string iComment;
+	string iName;
+	vector<char> iBytes;
+	bool iIsRedirectedToExactCopy;
+	};
+
+CMLCompDataInstOptImpl::CMLCompDataInstOptImpl(CCdlTkImplementation* aImpl)
+	:
+	iImpl(aImpl),
+	iIsRedirectedToExactCopy(false)
+	{
+	}
+
+CMLCompDataInstOptImpl::~CMLCompDataInstOptImpl()
+	{
+	}
+
+//
+// CMLCompDataLineInstOptImpl
+//
+
+class CMLCompDataLineInstOptImpl : public CMLCompDataInstOptImpl
+	{
+public:
+	CMLCompDataLineInstOptImpl(TMLCompDataLine* aLine, CCdlTkImplementation* aImpl);
+	virtual ~CMLCompDataLineInstOptImpl();
+public:
+	TMLCompDataLine* iLine;
+	};
+
+CMLCompDataLineInstOptImpl::CMLCompDataLineInstOptImpl(TMLCompDataLine* aLine, CCdlTkImplementation* aImpl)
+	: 
+	CMLCompDataInstOptImpl(aImpl),
+	iLine(aLine)
+	{
+	}
+
+CMLCompDataLineInstOptImpl::~CMLCompDataLineInstOptImpl()
+	{
+	}
+
+
+//
+// CMLCompDataSubTableInstOptImpl
+//
+
+class CMLCompDataSubTableInstOptImpl : public CMLCompDataInstOptImpl
+	{
+public:
+	CMLCompDataSubTableInstOptImpl(
+		TMLCompDataTable* aTable,
+		TMLCompDataTable::TMLCompDataSubTable* aSubTable, 
+		CCdlTkImplementation* aImpl);
+	virtual ~CMLCompDataSubTableInstOptImpl();
+public:
+	TMLCompDataTable* iTable;
+	TMLCompDataTable::TMLCompDataSubTable* iSubTable;
+	};
+
+CMLCompDataSubTableInstOptImpl::CMLCompDataSubTableInstOptImpl(
+	TMLCompDataTable* aTable,
+	TMLCompDataTable::TMLCompDataSubTable* aSubTable, 
+	CCdlTkImplementation* aImpl)
+	:
+	iTable(aTable),
+	CMLCompDataInstOptImpl(aImpl),
+	iSubTable(aSubTable)
+	{
+	}
+
+CMLCompDataSubTableInstOptImpl::~CMLCompDataSubTableInstOptImpl()
+	{
+	}
+
+
+//
+// CMLCompDataInstOpt
+//
+
+class CMLCompDataInstOpt
+	{
+public:
+	CMLCompDataInstOpt(MLCompDataCdlInstanceOpt& aInstances, TMLCompData* aLayout, const string& aInstName, const string& aZoomName, int aZoomLevel, bool aAllParams, bool aNonCompleteInstance);
+	~CMLCompDataInstOpt();
+
+	void Process(const string& aFirstInstanceName);
+	void WriteInstance();
+
+	CCdlTkInstance& Inst() const { return *iInstance; }
+	string Name() const { return iName; }
+	string ZoomName() const { return iZoomName; }
+
+private:
+	typedef vector<int> ParamLimitVarieties;
+	typedef vector<ParamLimitVarieties> ParamLimits;
+	typedef map<int, int> IndexMap;
+
+private:
+	void ProcessLines(TMLCompDataTable& aTable);
+	void ProcessTables(TMLCompDataTable& aTable);
+	void ProcessLine(TMLCompDataLine& aLine);
+	void ProcessLineApi(TMLCompDataLine& aLine, CCdlTkImplementation& aImpl);
+	void UpdateBaseOffset();
+	void UpdateLine(CMLCompDataInstOptImpl& aImpl, int& aByteCodeSizeDelta);
+	void UpdateLineImpls();
+	void UpdateLineImplDefn(CMLCompDataInstOptImpl& aImpl);
+	void UpdateTableInstance(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub, CMLCompDataInstOptImpl* aImpl);
+
+	void SetNewLineData(CMLCompDataLineInstOptImpl& aImpl);
+	void SetNewLineParamData(CMLCompDataLineInstOptImpl& aImpl, IndexMap& aIndexMap, int aTotalMax, int aNumVarieties);
+	void OptimizeNewLineData(CMLCompDataLineInstOptImpl& aImpl, IndexMap& aIndexMap, vector<char>& aTempBytes, const vector<string>& aOutputOrder, bool aMirrored, int aTotalMax, int aNumVarieties);
+	void OptimizeNewLineCellData(IndexMap& aIndexMap, vector<char>& aTempBytes, TMLCompDataValues& aValues, unsigned int& aNextCell, int aTotalParams, int aNumVarieties, ParamLimitVarieties& aParamLimitVarieties, string cellName, bool aMirrorJustification);
+	void EncodeNewLineCellData(IndexMap& aIndexMap, vector<char>& aTempBytes, vector<string>& aValuesToEncode, unsigned int& aNextCell, int aTotalMax, bool aOptimizeVarieties, bool aOptimizeCalcs);
+
+	bool HasApi(const string& aName);
+	CCdlTkImplementation& FindImp(const string& aName);
+	CMLCompDataInstOptImpl* FindSimilarImpl(const CMLCompDataInstOptImpls& aImpls, const CCdlTkImplementation& aImpl);
+	string DefinitionString(int aByteCodeIndex, const string& aApiName);
+	bool CheckByteCodeIndexInRange(int aByteCodeIndex);
+
+	void SetGenericFunc(CMLCompDataInstOptImpl& aImpl, SCompDataImplFunc::TFuncType aType);
+	void SetLineFunc(CMLCompDataLineInstOptImpl& aImpl);
+	void SetSubTableFunc(CMLCompDataSubTableInstOptImpl& aImpl);
+	void SetParamLimits(CMLCompDataLineInstOptImpl& aImpl);
+
+	void ValidateRequiredParams(string aApiName, CCdlTkApiParams& aParams, bool aOption, bool aColumn, bool aRow);
+	void CountApiParams(CCdlTkImplementation& aApi, int& aParams);
+	SCompDataImplFunc& AddImplFunc(SCompDataImplFunc::TFuncType aType);
+	SCompDataImplFunc& AddImplFunc(SCompDataImplFunc::TFuncType aType, CCdlTkApiParams& aParams);
+
+	void SetGenericAPI(SCompDataImplFunc::TFuncType aType, const string& aName);
+	void SetExtraCpp(const string& aFirstInstanceName);
+	void OutputStats();
+
+	void AddTableToInstance(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub, int aTableNum);
+	void UpdateTables(TMLCompDataTable& aTable);
+	void AddTableParamLimitsImpl(const string& aApiName, int aByteCodeIndex, SCompDataImplFunc::TFuncType aType, bool aNeedsOptions);
+	void UpdateTableParamLimitsImpl(const string& aApiName, int aByteCodeIndex);
+	void AddTableLimitsImpl(const string& aApiName, TMLCompDataTable::TMLCompDataSubTable& aSubTable);
+	void AddTableLimitsImplDefn(TMLCompDataTable::TMLCompDataSubTable& aSubTable, CCdlTkImplementation& aImpl);
+	void AddTableImpl(const string& aApiName, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub);
+	void AddParamLimits(TMLCompDataLine& aLine, bool aNeedsOptions);
+	void UpdateParamLimits(const string& apiName);
+	void SetDummyTableData(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CMLCompDataInstOptImpl& aImpl);
+	void UpdateTableData(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CMLCompDataInstOptImpl& aImpl);
+	void EncodeValue(vector<char>& aBytes, string aValue);
+	void EncodeValue(vector<char>& aBytes, int aValue);
+	void EncodeParentRelativeValue(vector<char>& aBytes, int aValue);
+	void MirrorParamName(string& aParamName);
+
+private:
+	MLCompDataCdlInstanceOpt& iInstances;
+	TMLCompData* iLayout;
+	string iName;
+	string iZoomName;
+	CCdlTkInterface& iInterface;
+	CCdlTkInstance* iInstance; // not owned
+	CMLCompDataInstOptImpls iImpls;
+	CMLCompDataInstOptImpls iTableImpls;
+	typedef vector<SCompDataImplFunc*> CImplFuncs;
+	CImplFuncs iFuncs;
+	int iZoomLevel;
+	bool iAllParams;
+	int iBaseOffset; // offset from the start of the main data table to the start of this instance's data
+	};
+
+CMLCompDataInstOpt::CMLCompDataInstOpt(MLCompDataCdlInstanceOpt& aInstances, TMLCompData* aLayout, const string& aInstName, const string& aZoomName, int aZoomLevel, bool aAllParams, bool aNonCompleteInstance)
+	: 
+	iInstances(aInstances), 
+	iLayout(aLayout),
+	iName(aInstName), 
+	iZoomName(aZoomName), 
+	iZoomLevel(aZoomLevel),
+	iInterface(iInstances.Interface()),
+	iAllParams(aAllParams),
+	iBaseOffset(0)
+	{
+	string zoomInstName = aInstName;
+	if(aZoomName.length() > 0)
+		zoomInstName += "_" + aZoomName;
+
+	iInstance = new CCdlTkInstance(iInterface);
+	iInstance->SetName(zoomInstName);
+
+	CCdlTkImplementations& impl = iInstance->Impl();
+	for (CCdlTkImplementations::iterator pImpl = impl.begin(); pImpl != impl.end(); ++pImpl)
+		{
+		const CCdlTkInterface& iface = (*pImpl)->Instance().Interface();
+		const CCdlTkApi& api = (*pImpl)->Api();
+		if(aLayout->iIsBaseInstance)
+			{
+			// for a base instance, need to set a default implementation
+			// even for missing data
+			(*pImpl)->SetDefinition(CdlTkUtil::ShortToHexString(0) + ",\t// " + KDefinitionNotDefined);
+			
+			// preliminary implementation of "blank" implementation. cdl engine searches to ensure that
+			// all implementations are not NULL. So this will satisfy that test. However, if any of the 
+			// methods are called, there will be an access violation, which will cause a panic
+			// this will be a successful guide to implementers not to call the API when the wrong layout
+			// pack is installed.
+			string definition = "(" + iface.NamespaceName() + "::" + api.PointerType() + ")((void*)4), // LAYOUT NOT DEFINED FOR THIS INSTANCE";
+			(*pImpl)->SetPointerReference(definition); 
+			}
+        else if(aNonCompleteInstance)
+            {
+			// for a base instance, need to set a default implementation
+			// even for missing data
+			(*pImpl)->SetDefinition(CdlTkUtil::ShortToHexString(0) + ",\t// " + KDefinitionNotDefined);
+
+            // but we need the pointer to be null so that CdlEngine falls through the layer below
+			string definition =  "0, // " + iface.NamespaceName() + "::" + api.PointerType();
+			(*pImpl)->SetPointerReference(definition); 
+            }
+        else
+			{
+			// Initially set definition that will not compile in the resulting code.
+			// This will alert the programmer to missing layout data.
+			(*pImpl)->SetDefinition(KDefinitionNotSet);
+			}
+		}
+	}
+
+CMLCompDataInstOpt::~CMLCompDataInstOpt()
+	{
+	delete iInstance;
+	for (CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		delete *pImpl;
+	for (pImpl = iTableImpls.begin(); pImpl != iTableImpls.end(); ++pImpl)
+		delete *pImpl;
+	}
+
+void CMLCompDataInstOpt::Process(const string& aFirstInstName)
+	{
+	iLayout->Compile();
+
+	for (TMLCompData::iterator pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab)
+		{
+		ProcessLines(**pTab);
+		}
+
+	for (pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab)
+		{
+		ProcessTables(**pTab);
+		}
+
+	// update the base offset to include all the data added, including reserving space for the tables
+	UpdateBaseOffset();
+
+	// with the correct base offset, the definitions can be updated
+	UpdateLineImpls();
+
+	for (pTab = iLayout->begin(); pTab != iLayout->end(); ++pTab)
+		{
+		// now that the rest of the data is stable, we can add the tables at the end
+		UpdateTables(**pTab);
+		}
+
+	SetGenericAPI(SCompDataImplFunc::EGenericComponentType, KFuncGetComponentTypeById);
+	SetGenericAPI(SCompDataImplFunc::EGenericParamLimits, KFuncGetParamLimitsById);
+	SetGenericAPI(SCompDataImplFunc::EGenericWindowComponent, KFuncGetWindowComponentById);
+	SetGenericAPI(SCompDataImplFunc::EGenericTextComponent, KFuncGetTextComponentById);
+	
+	SetExtraCpp(aFirstInstName);
+	OutputStats();
+	}
+
+void CMLCompDataInstOpt::WriteInstance()
+	{
+	CCdlTkWriteInstance writer(*iInstance);
+	writer.Process();
+	}
+
+void CMLCompDataInstOpt::ProcessLines(TMLCompDataTable& aTable)
+	{
+	for (TMLCompDataTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		ProcessLine(**pLine);
+		}
+	}
+
+void CMLCompDataInstOpt::ProcessTables(TMLCompDataTable& aTable)
+	{
+	int line = 0;
+	for (TMLCompDataTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		for (TMLCompDataTable::TMLCompDataSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+			{
+			TMLCompDataTable::TMLCompDataSubTable& sub = **pSub;
+			int last = *(sub.rbegin());
+			if(line == last)
+				AddTableToInstance(aTable, sub, 0);
+			}
+		line++;
+		}
+	}
+
+void CMLCompDataInstOpt::ProcessLine(TMLCompDataLine& aLine)
+	{
+	string apiName = MLCompDataToCdl::LineApiName(aLine);
+	if (!HasApi(apiName))
+		return;
+
+	ProcessLineApi(aLine, FindImp(apiName));
+	}
+
+void CMLCompDataInstOpt::ProcessLineApi(TMLCompDataLine& aLine, CCdlTkImplementation& aImpl)
+	{
+	string lineName = MLCompDataToCdl::LineApiName(aLine);
+
+	CMLCompDataLineInstOptImpl* newImpl = new CMLCompDataLineInstOptImpl(&aLine, &aImpl);
+	iImpls.push_back(newImpl);
+
+	// always set the new line data
+	SetNewLineData(*newImpl);
+
+	// if we can find the new line data in the aggregated data, point to that instead
+	int foundIndex = iInstances.FindSimilarBytes(newImpl, iBaseOffset);
+	if(foundIndex >= 0)
+		{
+		newImpl->iByteCodeIndex = foundIndex;
+		newImpl->iIsRedirectedToExactCopy = true;
+		}
+	else
+		{
+		iInstances.AddImpl(newImpl);
+		}
+
+	SetLineFunc(*newImpl);
+
+	// only add parameter limits if the line is not simple
+	// and we must add the param limits after the actual impl, so that we can find it!
+	bool needsParamLimits = aLine.NeedsOptions() || aLine.NeedsCols() || aLine.NeedsRows();
+	if(needsParamLimits)
+		{
+		AddParamLimits(aLine, aLine.NeedsOptions());
+		}
+	}
+
+void CMLCompDataInstOpt::UpdateBaseOffset()
+	{
+	// have to account for this instance's tables
+	int tablesSize(0);
+	for(CMLCompDataInstOptImpls::iterator pTableImpl = iTableImpls.begin(); pTableImpl != iTableImpls.end(); ++pTableImpl)
+		{
+		CMLCompDataInstOptImpl* impl = *pTableImpl;
+		tablesSize += impl->iBytes.size();
+		}
+
+	int origByteStreamSize = iInstances.ByteStreamSize() + tablesSize;
+
+	// repeat until base offset stabilizes
+	iBaseOffset = max(0, origByteStreamSize - KAddressableBytecodedData);
+	int newBaseOffset = iBaseOffset;
+	int byteCodeSizeDelta(0);
+	do
+		{
+		iBaseOffset = newBaseOffset;
+		for(CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+			UpdateLine(**pImpl, byteCodeSizeDelta);
+		newBaseOffset = max(0, origByteStreamSize + byteCodeSizeDelta - KAddressableBytecodedData);
+		}
+	while(iBaseOffset != newBaseOffset);
+	}
+
+void CMLCompDataInstOpt::UpdateLine(CMLCompDataInstOptImpl& aImpl, int& aByteCodeSizeDelta)
+	{
+	if(aImpl.iIsRedirectedToExactCopy && aImpl.iByteCodeIndex < iBaseOffset)
+		{
+		// when we encoded the impls, we found a match in an area which now
+		// turns out to be before the base offset (i.e. outside the addressable range).
+
+		// first of all check in case we've already made another copy close by
+		int foundIndex = iInstances.FindSimilarBytes(&aImpl, iBaseOffset);
+		if(foundIndex >= 0)
+			{
+			aImpl.iByteCodeIndex = foundIndex;
+			}
+		else
+			{
+			// add its bytecodes to the end
+			aImpl.iIsRedirectedToExactCopy = false;
+			iInstances.AddImpl(&aImpl);
+			aByteCodeSizeDelta += aImpl.iBytes.size();
+			}
+		}
+	}
+
+
+void CMLCompDataInstOpt::UpdateLineImpls()
+	{
+	for(CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		UpdateLineImplDefn(**pImpl);
+	}
+
+void CMLCompDataInstOpt::UpdateLineImplDefn(CMLCompDataInstOptImpl& aImpl)
+	{
+	if(!CheckByteCodeIndexInRange(aImpl.iByteCodeIndex))
+		throw GeneralErr(aImpl.iName + " in interface " + iInterface.FileName());
+	// the base offset has been updated, so all definitions must be refreshed
+	int adjustedIndex = aImpl.iByteCodeIndex - iBaseOffset;
+	aImpl.iImpl->SetDefinition(DefinitionString(aImpl.iByteCodeIndex, aImpl.iName));
+	UpdateParamLimits(aImpl.iName); 
+	}
+
+void CMLCompDataInstOpt::UpdateTables(TMLCompDataTable& aTable)
+	{
+	// regenerate the byte code indices, in case they have changed
+	int line = 0;
+	for (TMLCompDataTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		for (TMLCompDataTable::TMLCompDataSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+			{
+			TMLCompDataTable::TMLCompDataSubTable& sub = **pSub;
+			int last = *(sub.rbegin());
+			if(line == last)
+				{
+				string tableName = MLCompDataToCdl::SubTableApiName(sub);
+				CMLCompDataInstOptImpl* impl = FindSimilarImpl(iTableImpls, FindImp(tableName));
+				UpdateTableInstance(aTable, sub, impl);
+				}
+			}
+		line++;
+		}
+	}
+
+void CMLCompDataInstOpt::SetNewLineData(CMLCompDataLineInstOptImpl& aImpl)
+	{
+	aImpl.iBytes.clear();	
+
+	TMLCompDataLine& line = *aImpl.iLine;
+	aImpl.iComment = string("for line: ");
+	aImpl.iName = MLCompDataToCdl::LineApiName(line);
+
+	// handle mirroring order
+	bool mirrored = false;
+	if(line.iParentTable) // we know top table can't be mirrored
+		mirrored = line.iParentTable->iTables->iCanBeMirror;
+	const string* outputOrder =  mirrored ? 
+		KCompDataGraphicOutputOrderMirrored : KCompDataGraphicOutputOrder;
+	int outputSize = KCompDataGraphicOutputOrderSize;
+	if (line.iType == TMLCompDataLine::ETextComponent)
+		{
+		outputOrder = mirrored ? 
+			KCompDataTextOutputOrderMirrored : KCompDataTextOutputOrder;
+		outputSize = KCompDataTextOutputOrderSize;
+		}
+	vector<string> cellOrder(outputOrder, outputOrder + outputSize);
+
+	// we are currently storing variety as max allowed value, but it's a zero based index
+	int numVarieties = line.MaxVariety() + 1;
+
+	// we will be storing all of the rows and cols, even if the rows and cols limits are lower
+	int totalMaxCols = numVarieties * line.NumCols();
+	int totalMaxRows = numVarieties * line.NumRows();
+    int totalMax = totalMaxCols > totalMaxRows ? totalMaxCols : totalMaxRows;
+
+	// initialize the temporary bytestream, and the index map
+	vector<char> tempBytes;
+	IndexMap indexMap;
+
+	// fill in the temp byte stream and the index map for each cell
+	OptimizeNewLineData(aImpl, indexMap, tempBytes, cellOrder, mirrored, totalMax, numVarieties);
+
+	// encode the index map
+	SetNewLineParamData(aImpl, indexMap, totalMax, numVarieties);
+
+	// finally copy the temp byte stream onto the end of the real encoded byte stream
+	copy(tempBytes.begin(), tempBytes.end(), back_inserter(aImpl.iBytes));
+	}
+
+void CMLCompDataInstOpt::SetNewLineParamData(CMLCompDataLineInstOptImpl& aImpl, IndexMap& aIndexMap, int aTotalMax, int aNumVarieties)
+	{
+	// only set parameter data if the line is not simple
+	TMLCompDataLine& line = *aImpl.iLine;
+	
+	bool needsHeader = line.NeedsOptions() || line.NeedsCols() || line.NeedsRows();
+
+	int typeBitfield = line.iType << 1;
+	if(needsHeader)
+		{
+		typeBitfield |= 1;
+		}
+	
+	aImpl.iBytes.push_back(typeBitfield);
+
+	if(needsHeader)
+		{
+		// we can just dump the number of varieties, this will be used by the limits API
+		// and we can also them to calculate value indices within a cell when decoding
+		aImpl.iBytes.push_back(aNumVarieties);
+		}
+
+	//  count the number of cells that are complex
+	char numMultiValues = aIndexMap.size();
+	if(needsHeader)
+		{
+		aImpl.iBytes.push_back(numMultiValues);
+		}
+	else
+		{
+		// we didn't think we needed a header, so there should be no complex cells!
+		if (numMultiValues > 0)
+			throw GeneralErr("complex cells detected in simple line");
+		}
+
+	// for each complex cell, encode the bitfield and the count
+	for(IndexMap::iterator pIndex = aIndexMap.begin(); pIndex != aIndexMap.end(); ++pIndex)
+		{
+		int count = pIndex->first;
+		int index = pIndex->second;
+		EncodeValue(aImpl.iBytes, index);
+		EncodeValue(aImpl.iBytes, count);
+		}
+	}
+
+void CMLCompDataInstOpt::OptimizeNewLineData(
+	CMLCompDataLineInstOptImpl& aImpl, 
+	IndexMap& aIndexMap, 
+	vector<char>& aTempBytes,
+	const vector<string>& aOutputOrder,
+	bool aMirrored,
+	int aTotalMax, 
+	int aNumVarieties)
+	{
+	vector<ParamLimitVarieties> paramLimits;
+	TMLCompDataLine& line = *aImpl.iLine;
+
+	// start by extracting the row and column data. 
+	// we can optimize the stored format along with the rest of the data
+	// so no need to optimize it yet
+	for(int cell = 0; cell < 2; cell++)
+		{
+		string cellName = aOutputOrder[cell];
+		ParamLimitVarieties nextLimits;
+		TMLCompDataValues& values = line[cellName];
+		for(int varietyIndex = 0; varietyIndex < aNumVarieties; varietyIndex++)
+			{
+			TMLCompDataZoomLevels& zoomLevels = values[varietyIndex];
+			TMLCompDataCalcs* calcs = &(zoomLevels[iZoomLevel]);
+			if(!calcs->size())
+				calcs = &(zoomLevels[EAknUiZoomNormal]);
+			int value = CdlTkUtil::ParseInt((*calcs)[0]);
+			nextLimits.push_back(value);
+			}
+		paramLimits.push_back(nextLimits);
+		}
+
+	// calculate the number of values
+	bool needsHeader = line.NeedsOptions() || line.NeedsCols() || line.NeedsRows();
+	unsigned int nextCellFlag = 1;	// bit flag for the next cell, note it can get bigger than a char
+	for (cell = 0; cell < aOutputOrder.size(); cell++)
+		{
+		string cellName = aOutputOrder[cell];
+		TMLCompDataValues::TCompDataCellType type = TMLCompDataValues::Type(cellName);
+		if(!needsHeader && type == TMLCompDataValues::ECellTypeParamLimit)
+			{
+			// if we don't need header, then don't output the param limits values
+			// although we'll still use them internally
+			continue;
+			}
+
+		int paramLimitsIndex = TMLCompDataValues::Type(cellName) == TMLCompDataValues::ECellTypeCol ? 0 : 1; // if it's not a row or col, it doesn't matter what param limits are used.
+		TMLCompDataValues& values = line[cellName];
+		int numValues = 0;
+		if(type == TMLCompDataValues::ECellTypeCol || type == TMLCompDataValues::ECellTypeRow)
+			{
+			ParamLimitVarieties& nextLimits = paramLimits[paramLimitsIndex];
+			numValues = std::accumulate(nextLimits.begin(), nextLimits.end(), 0);
+			}
+		else
+			{
+			numValues = aNumVarieties;
+			}
+
+		bool mirrorJustification = (aMirrored && cellName == KCellNameJustification);
+		OptimizeNewLineCellData(aIndexMap, aTempBytes, values, nextCellFlag, numValues, aNumVarieties, paramLimits[paramLimitsIndex], cellName, mirrorJustification);
+		}
+	}
+
+void CMLCompDataInstOpt::OptimizeNewLineCellData(
+	IndexMap& aIndexMap, 
+	vector<char>& aTempBytes, 
+	TMLCompDataValues& aValues, 
+	unsigned int& aNextCell, 
+	int aTotalParams,
+	int aNumVarieties, 
+	CMLCompDataInstOpt::ParamLimitVarieties& aParamLimitVarieties, 
+	string cellName,
+	bool aMirrorJustification)
+	{
+	// build up the values for each variety 
+	// if the valid values for each variety are the same, then we can store them once only
+	// in which case there will be as many values as the variety with the largest number of values
+	vector<string> optimizedValues; 
+
+	// also build up the found valid values in case we can't optimize
+	vector<string> foundValues; 
+
+	bool optimizeVarieties = true;
+	bool optimizeCalcs = true;
+	int numCalcs = 0;
+	int* largestParamLimitPtr = max_element(aParamLimitVarieties.begin(), aParamLimitVarieties.end());
+	int largestParamLimit = largestParamLimitPtr != aParamLimitVarieties.end() ? *largestParamLimitPtr : 0;
+	
+	// in the case of there being no calcs at all, we don't want to be optimizing,
+	// in order to avoid wasted flags.
+	if(largestParamLimit == 1)
+		optimizeCalcs = false;
+
+	TMLCompDataValues::TCompDataCellType type = TMLCompDataValues::Type(cellName);
+	bool isColRow = (type == TMLCompDataValues::ECellTypeCol ||	type == TMLCompDataValues::ECellTypeRow);
+
+	// only go up to the max variety, as any data past that may be from a spurious merged instance
+	for(int varietyIndex = 0; varietyIndex < aNumVarieties; varietyIndex++)
+		{
+		TMLCompDataZoomLevels& zoomLevels = aValues[varietyIndex];
+		TMLCompDataCalcs* calcs = &(zoomLevels[iZoomLevel]);
+		if(!calcs->size())
+			calcs = &(zoomLevels[EAknUiZoomNormal]);
+		numCalcs = calcs->size();
+		string value;
+		vector<string> foundCalcs; 
+		int paramLimit = aParamLimitVarieties[varietyIndex];
+		if(numCalcs == 0)
+			{
+			if(varietyIndex == 0)
+				optimizedValues.push_back(value);
+			if(varietyIndex > 0 && !(optimizedValues[0].empty()))
+				optimizeVarieties = false;
+			foundCalcs.push_back(value);
+			}
+		else
+			{
+			for(int index = 0; index < numCalcs; index++)
+				{
+				bool needToCheckIndexValidity = !isColRow || (index < paramLimit);
+				value = (*calcs)[index];
+				value = aMirrorJustification ? TMLCompDataValues::MirrorJustificationValue(value) : value;
+
+				if(index >= optimizedValues.size() && index < largestParamLimit) // index is zero based, size is quantity
+					{
+					// store the first valid value for a given index that we find.
+					// note that this will pick up additional values in subsequent varieties
+					optimizedValues.push_back(value);
+					}
+				else if(needToCheckIndexValidity && value != optimizedValues[index]) 
+					{
+					// so if it doesn't match, we can't optimize
+					optimizeVarieties = false;
+					}
+
+				// collect the valid found values as we go, in case we aren't able to optimize
+				if(needToCheckIndexValidity)
+					{
+					foundCalcs.push_back(value);
+					}
+				}
+			}
+		if(isColRow)
+			{
+			int found = foundCalcs.size();
+			if(!found)
+				{
+				foundCalcs.push_back(string());
+				found++;
+				}
+			if(found > 1)
+				{
+				optimizeCalcs = false;
+				}
+			}
+		else
+			{
+			optimizeCalcs = false;
+			}
+		copy(foundCalcs.begin(), foundCalcs.end(), back_inserter(foundValues));
+		}
+
+	if(optimizeVarieties && isColRow)
+		{
+		// now that we know the optimized values, fill missing values by repeating the last one.
+		// but if we're optimizing the calcs, then we don't want to expand them after all
+		if(!optimizeCalcs)
+			{
+			int optimal = optimizedValues.size();
+			string value = optimal > 0 ? optimizedValues[optimal-1] : string();
+			for(; optimal < largestParamLimit; optimal++)
+				{
+				optimizedValues.push_back(value);
+				}
+			}
+		}
+
+	if(optimizeVarieties && aNumVarieties == 1)
+		{
+		optimizeVarieties = false;
+		}
+
+	vector<string>& valuesToEncode = optimizeVarieties ? optimizedValues : foundValues;
+	EncodeNewLineCellData(aIndexMap, aTempBytes, valuesToEncode, aNextCell, aTotalParams, optimizeVarieties, optimizeCalcs);
+	}
+
+void CMLCompDataInstOpt::EncodeNewLineCellData(
+	IndexMap& aIndexMap, 
+	vector<char>& aTempBytes, 
+	vector<string>& aValuesToEncode, 
+	unsigned int& aNextCell,
+	int aTotalMax,
+	bool aOptimizeVarieties,
+	bool aOptimizeCalcs)
+	{
+	// encode the actual data into the temporary bytestream
+	int numOptimizedVals = aValuesToEncode.size();
+	if(numOptimizedVals > 0)
+		{
+		for(vector<string>::iterator pString = aValuesToEncode.begin(); pString != aValuesToEncode.end(); ++pString)
+			{
+			EncodeValue(aTempBytes, *pString);
+			}
+		}
+	else
+		{
+		EncodeValue(aTempBytes, "");
+		}
+
+	if(numOptimizedVals > aTotalMax)
+		throw GeneralErr("bad index in indexMap");
+	
+	// if there is only one value stored, we can make a further optimization
+	// as we know that all values must be the same, however they are stored
+	// so in that case, don't store an index map entry
+	if(numOptimizedVals > 1)
+		{
+		// update the index map, 
+		// put the flags at the right hand side, to avoid it becoming multi-byte in general
+		int optimizeVarietiesMask = (aOptimizeVarieties ? 1 : 0);
+		int optimizeCalcsMask = (aOptimizeCalcs ? 1 : 0) << 1;
+		int numValsMask = (numOptimizedVals) << 2;
+		int indexField = (numValsMask | optimizeCalcsMask | optimizeVarietiesMask);
+		aIndexMap[indexField] |= aNextCell;
+		}
+	aNextCell = aNextCell << 1;
+	}
+
+void CMLCompDataInstOpt::CountApiParams(CCdlTkImplementation& aApi, int& aParams)
+	{
+	aParams = 0;
+	const CCdlTkApiParams& params = aApi.Api().AsFunc().Params();
+	for (CCdlTkApiParams::const_iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		{
+		if (pParam->Type() == KTypeInt) // is it a cell index parameter
+			aParams++;
+		}
+	}
+
+void CMLCompDataInstOpt::ValidateRequiredParams(string aApiName, CCdlTkApiParams& aParams, bool aOption, bool aColumn, bool aRow)
+	{
+	// check that data matches api
+	bool matches = true;
+	matches &= ((aOption) == (aParams.FindByName(KParamOptionIndex) != aParams.end()));
+	matches &= ((aColumn) == (aParams.FindByName(KParamColIndex) != aParams.end()));
+	matches &= ((aRow) == (aParams.FindByName(KParamRowIndex) != aParams.end()));
+	if(!matches)
+		throw CdlTkAssert(string("layout data does not match CDL API : ") + aApiName);
+	}
+
+void CMLCompDataInstOpt::SetGenericFunc(CMLCompDataInstOptImpl& aImpl, SCompDataImplFunc::TFuncType aType)
+	{
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(aImpl.iImpl->Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+
+	SCompDataImplFunc& func = AddImplFunc(aType, params);
+	aImpl.iImpl->SetPointerReference(func.iPtrRef);
+	}
+
+void CMLCompDataInstOpt::SetLineFunc(CMLCompDataLineInstOptImpl& aImpl)
+	{
+	SCompDataImplFunc::TFuncType type = SCompDataImplFunc::EWindowLine;
+	if (aImpl.iLine->iType == TMLCompDataLine::ETextComponent)
+		{
+		type = SCompDataImplFunc::ETextLine;
+		}
+	string name = aImpl.iImpl->Name();
+
+	// look up the api to see whether we need the params
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(aImpl.iImpl->Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+	ValidateRequiredParams(
+		name, 
+		params, 
+		iAllParams || aImpl.iLine->NeedsOptions(), 
+		iAllParams || aImpl.iLine->NeedsCols(), 
+		iAllParams || aImpl.iLine->NeedsRows());
+	SCompDataImplFunc& func = AddImplFunc(type, params);
+	aImpl.iImpl->SetPointerReference(func.iPtrRef);
+	}
+
+void CMLCompDataInstOpt::SetSubTableFunc(CMLCompDataSubTableInstOptImpl& aImpl)
+	{
+	TMLCompDataTable& table = *(aImpl.iTable);
+	TMLCompDataTable::TMLCompDataSubTable& subTable = *(aImpl.iSubTable);
+	TMLCompDataLine& line= *(table[subTable[0]]);
+
+	SCompDataImplFunc::TFuncType type = SCompDataImplFunc::EWindowTable;
+
+	if (line.iType == TMLCompDataLine::ETextComponent)
+		{
+		type = SCompDataImplFunc::ETextTable;
+		}
+	string name = aImpl.iImpl->Name();
+
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(aImpl.iImpl->Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+
+	string debug;
+	for(CCdlTkApiParams::iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		debug = pParam->Name();
+
+	ValidateRequiredParams(
+		name, 
+		params, 
+		iAllParams || subTable.iNeedsOption, 
+		iAllParams || subTable.iNeedsCol, 
+		iAllParams || subTable.iNeedsRow);
+	SCompDataImplFunc& func = AddImplFunc(type, params);
+	aImpl.iImpl->SetPointerReference(func.iPtrRef);
+	}
+
+bool CMLCompDataInstOpt::HasApi(const string& aName)
+	{
+	return iInterface.ApiList().Find(aName) != 0;
+	}
+
+CCdlTkImplementation& CMLCompDataInstOpt::FindImp(const string& aName)
+	{
+	CCdlTkImplementation* impl = iInstance->Impl().Find(aName);
+	if (!impl)
+		throw NotFoundErr(aName + " in interface " + iInterface.FileName());
+	return *impl;
+	}
+
+CMLCompDataInstOptImpl* CMLCompDataInstOpt::FindSimilarImpl(const CMLCompDataInstOptImpls& aImpls, const CCdlTkImplementation& aImpl)
+	{
+	for (CMLCompDataInstOptImpls::const_iterator pOptImpl = aImpls.begin(); pOptImpl != aImpls.end(); ++pOptImpl)
+		{
+		CMLCompDataInstOptImpl* optImpl = *pOptImpl;
+		if (optImpl->iImpl == &aImpl)
+			return optImpl;
+		}
+	return NULL;
+	}
+
+string CMLCompDataInstOpt::DefinitionString(int aByteCodeIndex, const string& aApiName)
+	{
+	int adjustedIndex = aByteCodeIndex - iBaseOffset;
+	return CdlTkUtil::ShortToHexString(adjustedIndex) + ",\t// (" + CdlTkUtil::IntToHexString(aByteCodeIndex) + ") " + aApiName;
+	}
+
+bool CMLCompDataInstOpt::CheckByteCodeIndexInRange(int aByteCodeIndex)
+	{
+	int adjustedIndex = aByteCodeIndex - iBaseOffset;
+	if(adjustedIndex > KAddressableBytecodedData)
+		{
+		cerr << "Error: Out of range: index = "  << CdlTkUtil::IntToHexString(aByteCodeIndex) << ", ";
+		cerr << "baseOffset = " << CdlTkUtil::IntToHexString(iBaseOffset ) << endl;
+		return false;
+		}
+	return true;
+	}
+
+SCompDataImplFunc& CMLCompDataInstOpt::AddImplFunc(SCompDataImplFunc::TFuncType aType)
+	{
+	CCdlTkApiParams params;
+	return AddImplFunc(aType, params);
+	}
+
+SCompDataImplFunc& CMLCompDataInstOpt::AddImplFunc(SCompDataImplFunc::TFuncType aType, CCdlTkApiParams& aParams)
+	{
+	for (CImplFuncs::iterator pFunc = iFuncs.begin(); pFunc != iFuncs.end(); ++pFunc)
+		{
+		SCompDataImplFunc& func = **pFunc;
+		if(func.IsSimilar(aType, aParams))
+			return func;
+		}
+
+	int count = gTheFuncs.size();
+	for (int ii=0; ii<count; ii++)
+		{
+		SCompDataImplFunc* func = &gTheFuncs[ii];
+		if(func->IsSimilar(aType, aParams)) 
+			{
+			iFuncs.push_back(func);
+			return *func;
+			}
+		}
+
+	throw NotFoundErr("implementation function");
+	return gTheFuncs[0];
+	}
+
+void CMLCompDataInstOpt::SetGenericAPI(SCompDataImplFunc::TFuncType aType, const string& aName)
+	{
+	CCdlTkImplementation* impl = iInstance->Impl().Find(aName);
+
+	// CMLCompDataInstOptImpl(CCdlTkImplementation* aImpl);
+	CMLCompDataInstOptImpl* newImpl = new CMLCompDataInstOptImpl(impl);
+	iImpls.push_back(newImpl);
+
+	SetGenericFunc(*newImpl, aType);
+	newImpl->iImpl->SetDefinition(CdlTkUtil::ShortToHexString(0) + ","); // no specific data for generic apis
+	}
+
+// The following strings and the SetExtraCpp() function build the gross structure of
+// the C++ customisation instance.
+// So far, the implementations are actually just 16-bit values, typically indexes into
+// the data lookup table. These need to be turned into an array by adding declarations
+// and brackets to the first and last implementations. Extra support functions are also
+// added.
+// extern string KScalableExtraCpp;
+string KScalableExtraCpp = "\
+#include \"aknlayout2scalabledecode.h\"\n\
+namespace $INTERFACE_NS { extern const TUint8 KByteCodedData_$FIRSTINSTANCENAME[]; }\n";
+
+//extern string KScalableInitialCpp;
+string KScalableInitialCpp ="\
+extern const TUint16 KDataLookup[$INTERFACE_NS::E_TApiId_TableSize];\n\
+const SCompDataImplData KImplData = { KDataLookup, $INTERFACE_NS::KByteCodedData_$FIRSTINSTANCENAME + $THISINSTANCEBASEOFFSET };\n\
+\n\
+$FUNCTIONS\
+\n\
+const TUint16 KDataLookup[$INTERFACE_NS::E_TApiId_TableSize] =\n\
+\t{\n";
+void CMLCompDataInstOpt::SetExtraCpp(const string& aFirstInstName)
+	{
+	// The "extra cpp" field is written to the top of the cpp file.
+	CdlTkUtil::CReplaceSet cppSet;
+	cppSet.Add("$INTERFACE_NS", iInterface.NamespaceName());
+	cppSet.Add("$FIRSTINSTANCENAME", aFirstInstName);
+	cppSet.Add("$THISINSTANCEBASEOFFSET", CdlTkUtil::IntToHexString(iBaseOffset)); // base offset can be longer than 16 bits
+	iInstance->SetExtraCpp(CdlTkUtil::MultiReplace(cppSet, KScalableExtraCpp));
+
+	// add headers & fwd declarations
+	string init = CdlTkUtil::MultiReplace(cppSet, KScalableInitialCpp);
+
+	// add decode functions
+	string functions;
+	for (CImplFuncs::iterator pFunc = iFuncs.begin(); pFunc != iFuncs.end(); ++pFunc)
+		{
+		CdlTkUtil::AppendString(functions, (*pFunc)->iDefn);
+		CdlTkUtil::AppendString(functions, "\n");
+		}
+	init = CdlTkUtil::Replace("$FUNCTIONS", functions, init);
+	CCdlTkImplementation& first = **(iInstance->Impl().begin());
+	first.SetDefinition(init + first.Definition());
+
+	// add end of data table
+	CCdlTkImplementation& last = **(iInstance->Impl().end() - 1);
+	last.SetDefinition(last.Definition() + "\n};");
+	}
+
+void CMLCompDataInstOpt::OutputStats()
+	{
+	int optimizedBytes(0);
+	int unoptimizedBytes(0);
+	for (CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		{
+		int size = (*pImpl)->iBytes.size();
+		if ((*pImpl)->iIsRedirectedToExactCopy)
+			optimizedBytes += size;
+		else
+			unoptimizedBytes += size;
+		}
+	for (CMLCompDataInstOptImpls::iterator pTableImpl = iTableImpls.begin(); pTableImpl != iTableImpls.end(); ++pTableImpl)
+		{
+		int size = (*pTableImpl)->iBytes.size();
+		if ((*pTableImpl)->iIsRedirectedToExactCopy)
+			optimizedBytes += size;
+		else
+			unoptimizedBytes += size;
+		}
+
+	float compress = (100.0 * (float)unoptimizedBytes) / ((float)optimizedBytes + (float)unoptimizedBytes);
+	int compressInt = (int)(compress + 0.5);
+	cout << "instance " << iName << " compressed to " << compressInt << "% of total (" << unoptimizedBytes<< " / " << optimizedBytes + unoptimizedBytes << ")" << endl;
+	}
+
+void CMLCompDataInstOpt::AddTableToInstance(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub, int /*aTableNum*/)
+	{
+	string tableName = MLCompDataToCdl::SubTableApiName(aSub);
+	string tableParamLimitsName = tableName + KFuncParamLimitsSuffix;
+
+	if (HasApi(tableName))
+		{
+		CCdlTkImplementation& impl = FindImp(tableName);
+		CMLCompDataSubTableInstOptImpl* newImpl = new CMLCompDataSubTableInstOptImpl(&aTable, &aSub, &impl);
+		iTableImpls.push_back(newImpl);
+
+		SetDummyTableData(aTable, aSub, *newImpl);
+		SetSubTableFunc(*newImpl);
+
+		AddTableLimitsImpl(tableName + KFuncLimitsSuffix, aSub);
+		if (HasApi(tableParamLimitsName))
+			{
+			AddTableParamLimitsImpl(tableParamLimitsName, newImpl->iByteCodeIndex, SCompDataImplFunc::ETableParamLimits, aSub.iNeedsOption);
+			}
+		AddTableImpl(tableName, aTable, aSub);
+		}
+	}
+
+void CMLCompDataInstOpt::UpdateTableInstance(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub, CMLCompDataInstOptImpl* aImpl)
+	{
+	string tableName = MLCompDataToCdl::SubTableApiName(aSub);
+	UpdateTableData(aTable, aSub, *aImpl);
+
+	// if we can find the new table data in the aggregated data, point to that instead
+	int foundIndex = iInstances.FindSimilarBytes(aImpl, iBaseOffset);
+	if(foundIndex >= 0)
+		{
+		if(foundIndex != aImpl->iByteCodeIndex)
+			{
+			aImpl->iByteCodeIndex = foundIndex;
+			aImpl->iIsRedirectedToExactCopy = true;
+			}
+		else
+			{
+			cerr << "Error: found same table already in bytestream: " << aImpl->iName << endl;
+			}
+		}
+
+	// now we've generated the bytecode, it will be added to the bytestream
+	iInstances.AddImpl(aImpl);
+	aImpl->iImpl->SetDefinition(DefinitionString(aImpl->iByteCodeIndex, tableName));
+
+	string tableParamLimitsName = tableName + KFuncParamLimitsSuffix;
+	if (HasApi(tableParamLimitsName))
+		{
+		UpdateTableParamLimitsImpl(tableParamLimitsName, aImpl->iByteCodeIndex);
+		}
+	}
+
+void CMLCompDataInstOpt::AddTableParamLimitsImpl(const string& aApiName, int aByteCodeIndex, SCompDataImplFunc::TFuncType aType, bool aNeedsOptions)
+	{
+	CCdlTkImplementation& impl = FindImp(aApiName);
+
+	// look up the api to see whether we need a variety params
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(impl.Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+	ValidateRequiredParams(
+		aApiName, 
+		params, 
+		iAllParams || aNeedsOptions, 
+		false, 
+		false);
+
+	SCompDataImplFunc& func = AddImplFunc(aType, params);
+
+	impl.SetDefinition(DefinitionString(aByteCodeIndex, aApiName));
+	impl.SetPointerReference(func.iPtrRef);
+	}
+
+void CMLCompDataInstOpt::UpdateTableParamLimitsImpl(const string& aApiName, int aByteCodeIndex)
+	{
+	CCdlTkImplementation& paramLimitsImpl = FindImp(aApiName);
+	paramLimitsImpl.SetDefinition(DefinitionString(aByteCodeIndex, aApiName));
+	}
+
+void CMLCompDataInstOpt::AddTableLimitsImpl(const string& aApiName, TMLCompDataTable::TMLCompDataSubTable& aSubTable)
+	{
+	CCdlTkImplementation& impl = FindImp(aApiName);
+	AddTableLimitsImplDefn(aSubTable, impl);
+	impl.SetPointerReference(AddImplFunc(SCompDataImplFunc::ETableLimits).iPtrRef);
+	}
+
+void CMLCompDataInstOpt::AddTableLimitsImplDefn(TMLCompDataTable::TMLCompDataSubTable& aSubTable, CCdlTkImplementation& aImpl)
+	{
+	// code up table limits as a pair of byte values, the first byte is the first table
+	// index, the second is the last table index.
+	int first = (*aSubTable.begin()) & 0xff;
+	int last = (*aSubTable.rbegin()) & 0xff;
+
+	// however, we want these APIs to be accessed zero based, so have to calculate the offset.
+	int offset = last - first;
+
+    int v = offset;
+	if ( v > KAddressableBytecodedData )
+	    {
+	    std::cerr << "*** ERROR: Value " << v << "(unknown/3) of out range" << std::endl;
+	    }
+	    
+	aImpl.SetDefinition(CdlTkUtil::ShortToHexString(offset) + KComma);
+	}
+
+void CMLCompDataInstOpt::AddTableImpl(const string& aApiName, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSub)
+	{
+	CCdlTkImplementation& impl = FindImp(aApiName);
+
+	int nParams;
+	CountApiParams(impl, nParams);
+	nParams--;	// don't count the aLineIndex param
+	SCompDataImplFunc::TFuncType type = SCompDataImplFunc::EWindowTable;
+	TMLCompDataLine::TComponentType subTableType = aTable[aSub[0]]->iType;
+	switch(subTableType)
+		{
+		case TMLCompDataLine::ETextComponent:
+			{
+			type = SCompDataImplFunc::ETextTable;
+			break;
+			}
+		}
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(impl.Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+	ValidateRequiredParams(
+		aApiName, 
+		params, 
+		iAllParams || aSub.iNeedsOption, 
+		iAllParams || aSub.iNeedsCol, 
+		iAllParams || aSub.iNeedsRow);
+	SCompDataImplFunc& func = AddImplFunc(type, params);
+	}
+
+void CMLCompDataInstOpt::AddParamLimits(TMLCompDataLine& aLine, bool aNeedsOptions)
+	{
+	string apiName = MLCompDataToCdl::LineApiName(aLine) ;
+	string paramLimitsApiName = apiName + KFuncParamLimitsSuffix;
+	if (!HasApi(paramLimitsApiName))
+		throw NotFoundErr(paramLimitsApiName + " in interface " + iInterface.FileName());
+
+	CCdlTkImplementation& paramLimitsImpl = FindImp(paramLimitsApiName);
+
+	// look up the api to see whether we need a variety params
+	CCdlTkFunctionApi& api = const_cast<CCdlTkFunctionApi&>(paramLimitsImpl.Api().AsFunc());
+	CCdlTkApiParams& params = api.Params();
+	ValidateRequiredParams(
+		paramLimitsApiName, 
+		params, 
+		iAllParams || aNeedsOptions, 
+		false, 
+		false);
+
+	SCompDataImplFunc& func = AddImplFunc(SCompDataImplFunc::ELineParamLimits, params);
+	paramLimitsImpl.SetPointerReference(func.iPtrRef);
+
+	UpdateParamLimits(apiName);
+	}
+
+void CMLCompDataInstOpt::UpdateParamLimits(const string& apiName)
+	{
+	string paramLimitsApiName = apiName + KFuncParamLimitsSuffix;
+	if (HasApi(paramLimitsApiName))
+		{
+		CCdlTkImplementation& paramLimitsImpl = FindImp(paramLimitsApiName);
+		CMLCompDataInstOptImpl* actualOptImpl = FindSimilarImpl(iImpls, FindImp(apiName));
+		
+		paramLimitsImpl.SetDefinition(DefinitionString(actualOptImpl->iByteCodeIndex, paramLimitsApiName));
+		}
+	}
+
+void CMLCompDataInstOpt::SetDummyTableData(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CMLCompDataInstOptImpl& aImpl)
+	{
+	aImpl.iBytes.clear();
+	aImpl.iComment = string("for table: ");
+	aImpl.iName = MLCompDataToCdl::SubTableApiName(aSubTable);
+	EncodeValue(aImpl.iBytes, aSubTable.size());
+	for(TMLCompDataTable::TMLCompDataSubTable::iterator pLineId = aSubTable.begin(); pLineId != aSubTable.end(); ++pLineId)
+		{
+		aImpl.iBytes.push_back(0);
+		aImpl.iBytes.push_back(0);
+		}
+	}
+
+void CMLCompDataInstOpt::UpdateTableData(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CMLCompDataInstOptImpl& aImpl)
+	{
+	aImpl.iBytes.clear();
+	EncodeValue(aImpl.iBytes, aSubTable.size());
+	for(TMLCompDataTable::TMLCompDataSubTable::iterator pLineId = aSubTable.begin(); pLineId != aSubTable.end(); ++pLineId)
+		{
+		// figure out the offset to the next line of the table
+		TMLCompDataLine& line = *(aTable[*pLineId]);
+		string lineName = MLCompDataToCdl::LineApiName(line) ;
+		CMLCompDataInstOptImpl* lineImpl = FindSimilarImpl(iImpls, FindImp(lineName));
+
+		// we must store the adjusted index, ie relative to the base offset, in the definition, as that will be used 
+		// in the main output, so check that the offset is in range, which it should be if we've updated the lines
+		// correctly
+		if(!CheckByteCodeIndexInRange(lineImpl->iByteCodeIndex))
+			throw GeneralErr(aImpl.iName + " in interface " + iInterface.FileName());
+		int adjustedIndex = lineImpl->iByteCodeIndex - iBaseOffset;
+
+		// make an assumption that data fits into 16 bits, and don't encode the lookups
+		// that way, when decoding, we can jump forward by 2 bytes * index without decoding
+		// all the values (since they're not encoded, we know they're all the same size)
+		aImpl.iBytes.push_back((adjustedIndex & 0xff00) >> 8);
+		aImpl.iBytes.push_back(adjustedIndex);
+		}
+	}
+
+struct SIdToInt
+	{
+	int iInt;
+	char* iStr;
+	};
+
+#include <avkon.hrh>
+extern SIdToInt gIdToIntTable[];
+extern const int gIdToIntTableCount;
+extern void TranslateValue(string& aValue);
+
+void CMLCompDataInstOpt::EncodeValue(vector<char>& aBytes, string aValue)
+	{
+	int pos = 0;
+	TranslateValue(aValue);
+	if (aValue == "")
+		{
+		aBytes.push_back(KByteEmpty);
+		}
+	else 
+		{
+		pos = aValue.find_first_of(KParentRelativeMarker);
+		if(pos != string::npos)
+			{
+			if (pos != 0)
+				throw CdlTkAssert(string("arithmetic parser not good enough : ") + aValue);
+			int val = CdlTkUtil::ParseInt(aValue.substr(1));
+			EncodeParentRelativeValue(aBytes, val);
+			}
+		else
+			{
+			int val = CdlTkUtil::ParseInt(aValue);
+			EncodeValue(aBytes, val);
+			}
+		}
+	}
+
+void CMLCompDataInstOpt::EncodeValue(vector<char>& aBytes, int aValue)
+	{
+	if (0 <= aValue && aValue <= KMaxSingleByteValue)
+		{
+		aBytes.push_back(aValue);
+		}
+	else if (aValue > KMaxSingleByteValue && aValue <= KMaxDoubleByteValue)
+		{
+		aBytes.push_back(KByteWord);
+		aBytes.push_back((aValue & 0xff00) >> 8);
+		aBytes.push_back(aValue);
+		}
+	else
+		{
+		aBytes.push_back(KByteLong);
+		aBytes.push_back((aValue & 0xff000000) >> 24);
+		aBytes.push_back((aValue & 0x00ff0000) >> 16);
+		aBytes.push_back((aValue & 0x0000ff00) >> 8);
+		aBytes.push_back(aValue);
+		}
+	}
+
+void CMLCompDataInstOpt::EncodeParentRelativeValue(vector<char>& aBytes, int aValue)
+	{
+	if (KMinSingleByteParentRelativeValue <= aValue && aValue <= KMaxSingleByteParentRelativeValue)
+		{
+		aBytes.push_back(KByteP1);
+		aBytes.push_back(aValue);
+		}
+	else
+		{
+		aBytes.push_back(KByteP2);
+		aBytes.push_back((aValue & 0xff00) >> 8);
+		aBytes.push_back(aValue);
+		}
+	}
+
+void CMLCompDataInstOpt::MirrorParamName(string& aParamName)
+	{
+	if (aParamName == KParamNameL)
+		aParamName = KParamNameR;
+	else if (aParamName == KParamNameR)
+		aParamName = KParamNameL;
+	}
+
+//
+// MLCompDataCdlInstanceOpt
+//
+
+MLCompDataCdlInstanceOpt::InstStruct::InstStruct(string aInstName, TMLCompData* aInst, TMLAttributes* aAttribs) 
+	: 
+	iInstName(aInstName), 
+	iInst(aInst),
+	iAttribs(aAttribs)
+	{
+	}
+
+MLCompDataCdlInstanceOpt::InstList::~InstList() 
+	{
+	for(InstList::iterator pNext = begin(); pNext != end(); ++pNext)
+		{
+		delete pNext->iInst;
+		}
+	}
+
+void MLCompDataCdlInstanceOpt::ProcessSeparators(vector<string>& args, vector<int>& aSeparators)
+	{
+    for(int arg = 3; arg < args.size(); arg++)
+        {
+        if(args[arg] == "-a")
+            aSeparators.push_back(arg);
+        }
+
+    aSeparators.push_back(args.size()); // add an implicit last separator
+    if(aSeparators.size() < 2)
+        throw MLCompDataCdlInstanceOptArgsErr();
+
+    // check that the distance between each separator is not a multiple of 2 
+    // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> sep) is 3 steps
+    // i.e. counting the steps between aSeparators ( sep -> xml -> inst -> xml -> inst -> sep) is 5 steps
+    for(int sep = 0; sep < aSeparators.size() - 1; sep++)
+        {
+        int delta = aSeparators[sep+1] - aSeparators[sep]; 
+	    if (delta%2 == 0)
+		    throw MLCompDataCdlInstanceOptArgsErr();
+        }
+	}
+
+bool MLCompDataCdlInstanceOpt::CheckForUsedInstances(
+	const CInstanceList& aUsedList, 
+	const CZoomLevelNames& aZoomLevelNames,
+	const vector<string>& aArgs, 
+	const vector<int>& aSeparators, 
+	int aSepIndex)
+	{
+	bool ok = false;
+	for(CZoomLevelNames::const_iterator pZoomLevel = aZoomLevelNames.begin(); pZoomLevel != aZoomLevelNames.end(); ++pZoomLevel)
+		{
+		// check if any of these instances are used - skip this if none are used
+		for (int arg = aSeparators[aSepIndex] + 1; arg < aSeparators[aSepIndex+1]; arg += 2)
+			{
+			string instName = aArgs[arg+1] + "_" + pZoomLevel->second;
+			if (aUsedList.IsInstanceOk(instName))
+				ok = true;
+			}
+		}
+	return ok;
+	}
+
+void MLCompDataCdlInstanceOpt::ParseInstances(const vector<string>& aArgs, const vector<int>& aSeparators, int aSepIndex, MLCompDataCdlInstanceOpt::InstList& aInstList)
+	{
+	for (int arg = aSeparators[aSepIndex] + 1; arg < aSeparators[aSepIndex+1]; arg += 2)
+		{
+		string layoutName = aArgs[arg];
+		string instName = aArgs[arg+1];
+		string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName);
+
+		auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName);
+		auto_ptr<TMLCompData> layout(layoutParse.get());
+		layoutParse.release();
+
+		auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName);
+		auto_ptr<TMLAttributes> attribs(attribsParse.get());
+		attribsParse.release();
+
+		InstStruct instStruct(instName, layout.get(), attribs.get());
+		aInstList.push_back(instStruct);
+		layout.release();
+		attribs.release();
+		}
+	}
+
+void MLCompDataCdlInstanceOpt::MergeLayouts(CInstanceList& aInstUsedList, CZoomLevelNames& aZoomLevelNames, const InstList& aInstances, InstList& aMergedLayouts)
+	{
+	// start with the non-mirrored instances
+	for(int count = 0; count < 2; count++)
+		{
+		bool isMirrored = (count != 0);
+		// first iterate through the layouts, we will generate one instance per layout
+		for(int instIndex = 0; instIndex < aInstances.size(); instIndex++)
+			{
+			const InstStruct& instStruct = aInstances[instIndex];
+			string targetInstName = instStruct.iInstName;
+			TMLCompData& targetLayout = *(instStruct.iInst);
+			TMLAttributes& targetAttribs = *(instStruct.iAttribs);
+
+			bool required = false;
+			for(CZoomLevelNames::const_iterator pZoomLevel = aZoomLevelNames.begin(); pZoomLevel != aZoomLevelNames.end(); ++pZoomLevel)
+				{
+				string zoomInstName = targetInstName + "_" + pZoomLevel->second;
+				 if(aInstUsedList.IsInstanceOk(zoomInstName))
+					required = true;
+				}
+
+			// if this target is not required, or if it's the wrong sort of mirrored
+			// for this iteration, skip it.
+			if(targetLayout.iCanBeMirror != isMirrored || !required)
+				continue;
+
+			// for each instance, we must merge all the other layouts
+			auto_ptr<TMLCompData> mergedLayout(new TMLCompData());
+			auto_ptr<TMLAttributes> mergedAttribs(new TMLAttributes());
+			for (InstList::const_iterator pInst2 = aInstances.begin(); pInst2 != aInstances.end(); ++pInst2)
+				{
+				// merge in all the others
+				const InstStruct& instStruct2 = *pInst2;
+				if(instStruct2.iInstName != targetInstName)
+					{
+					TMLCompData& nextLayout = *(instStruct2.iInst);
+					TMLAttributes& nextAttribs = *(instStruct2.iAttribs);
+					// but only if it's the right kind of mirrored
+					if(nextLayout.iCanBeMirror == isMirrored)
+						{
+						mergedLayout->Merge(nextLayout);
+						mergedAttribs->Merge(nextAttribs);
+						}
+					}
+				}
+			// then end up merging in the one we want
+			mergedLayout->Merge(targetLayout);
+			mergedAttribs->Merge(targetAttribs);
+			if(isMirrored)
+				{
+				// If we have just processed a mirrored layout, 
+				// we need to do a mirror merge with the corresponding one.
+				// The instances are ordered as on the command line, 
+				// but the merged layouts are grouped toghether, unmirrored first.
+				// So to convert between the two indexes: 1 -> 0, and 3 -> 1
+				int unMirroredMergedLayoutIndex = (instIndex / 2);
+				InstStruct& unMirroredInst = aMergedLayouts[unMirroredMergedLayoutIndex]; // this works as we have already added the unmirrored instance to the vector
+				TMLCompData& unMirroredLayout = *(unMirroredInst.iInst);
+				TMLAttributes& unMirroredAttribs = *(unMirroredInst.iAttribs);
+				mergedLayout->Merge(unMirroredLayout);
+				mergedAttribs->Merge(unMirroredAttribs);
+				}
+
+			InstStruct mergedInstStruct(targetInstName, mergedLayout.get(), mergedAttribs.get());
+			aMergedLayouts.push_back(mergedInstStruct);
+			mergedLayout.release();
+			mergedAttribs.release();
+			}
+		}
+	}
+
+int MLCompDataCdlInstanceOpt::Process(vector<string>& args)
+	{
+	// parse the file containing the used instances list. only instances in this list 
+	// will be generated, even if also mentioned on the command line
+	CInstanceList instUsedList;
+	instUsedList.ProcessOptions(args);
+
+	// extract the zoom level names, note that this consumes the argument if present
+	CZoomLevelNames zoomLevelNames;
+	zoomLevelNames.ProcessOptions(args);
+
+	// check that we have an acceptable number of arguments
+	int extraArgs = args.size() - 3;
+	if (extraArgs < 0)
+		throw MLCompDataCdlInstanceOptArgsErr();
+
+	// check for optional flags
+    int arg = 2;
+	bool allParams = false;
+	if (args[arg] == "-allparams")
+		{
+		allParams = true;
+		arg++;
+		}
+
+	bool nonCompleteInstance = false;
+	if(args[arg].substr(0,2) == "-d")
+        {
+		arg++;
+        if (args[arg].size() >= 2)
+		    {
+		    nonCompleteInstance = true;
+		    }
+        }
+
+	// parse the CDL interface
+	string cdlName = args[arg];
+	CCdlTkCdlFileParser parser(cdlName);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+	MLCompDataCdlInstanceOpt process(*iface);
+
+    // the separators divide the layout instances that are aggregated together
+    vector<int> separators;
+	ProcessSeparators(args, separators);
+    for(int sep = 0; sep < separators.size() - 1; sep++)
+        {
+		if(!CheckForUsedInstances(instUsedList, zoomLevelNames, args, separators, sep))
+			continue;
+        // start from after the next separator, and continue until before the next one
+	    InstList instances;
+		ParseInstances(args, separators, sep, instances);
+
+		InstList mergedLayouts;
+		MergeLayouts(instUsedList, zoomLevelNames, instances, mergedLayouts);
+		for(InstList::iterator pMergedLayout = mergedLayouts.begin(); pMergedLayout != mergedLayouts.end(); )
+			{
+			process.AddInst(*pMergedLayout, zoomLevelNames, allParams, nonCompleteInstance); // pass ownership of mergedLayout
+			pMergedLayout = mergedLayouts.erase(pMergedLayout);
+			}
+        }
+
+	process.Process();
+	process.WriteInstances();
+	return 0;
+	}
+
+void MLCompDataCdlInstanceOpt::ShowHelp(ostream& stream)
+	{
+	stream << "MLCompCdl2InstO [-i<instanceList>] [-z<zoomList>] [-allparams] [-d<deliveryType>] <interface.cdl> (-a ([-m]<layout.xml> <instanceName>)+ )+" << endl;
+	stream << "  Creates optimised CDL instances containing the layout data." << endl;
+	stream << "  Each -a flag is followed by a collection of xml and instance name pairs." << endl;
+	stream << "  Each collection is aggregated separately." << endl;
+	stream << "  The aggregation of the layout instances must conform to the CDL interface, " << endl;
+	stream << "    but note any missing data in an instance may result in data being returned " << endl;
+	stream << "    from a different instance, although duplicate implementations will be reused " << endl;
+	stream << "    to reduce ROM usage." << endl;
+	stream << "  A -m flag must precede an xml file that contains mirrored layout data." << endl;
+	stream << "  An aggregated collection of layouts must contain interleaved" << endl;
+	stream << "    elaf and the corresponding abrw instances." << endl;
+	stream << "  If -i<instanceList> is specified, then only instances whose name" << endl;
+	stream << "    appears in the file <instanceList> will be processed." << endl;
+	stream << "  If -z<zoomList> is specified, then only instances whose zoom factor" << endl;
+	stream << "   (in the form \"n,string\") appears in the file <zoomList> will be generated." << endl;
+	stream << "  If -allparams is used, all processed APIs will have all available params added, " << endl;
+	stream << "    otherwise only needed params are added." << endl;
+	stream << "  If -d<deliveryType> is supplied with any value, any API that has a missing" << endl;
+	stream << "    implementation will be filled in with NULL, allowing fall-through to an instance" << endl;
+	stream << "    from a lower priority pack." << endl;
+	}
+
+MLCompDataCdlInstanceOpt::MLCompDataCdlInstanceOpt(CCdlTkInterface& aInterface)
+	: 
+	iInterface(aInterface)
+	{
+	}
+
+MLCompDataCdlInstanceOpt::~MLCompDataCdlInstanceOpt()
+	{
+	for(CCompDataZoomLevelDatas::iterator pZoomLevel = iZoomLevelDatas.begin(); pZoomLevel != iZoomLevelDatas.end(); ++pZoomLevel)
+		{
+		CCompDatas& compDatas = pZoomLevel->second;
+		for (CCompDatas::iterator pInstOpt = compDatas.begin(); pInstOpt != compDatas.end(); ++pInstOpt)
+			delete *pInstOpt;
+		}
+	for(CCompDataLayouts::iterator pLayout = iLayouts.begin(); pLayout != iLayouts.end(); ++pLayout)
+		 delete *pLayout;
+	}
+
+void MLCompDataCdlInstanceOpt::AddInst(const InstStruct& aInstStruct, CZoomLevelNames& aZoomLevelNames, bool aAllParams, bool aNonCompleteInstance)
+	{
+	TMLCompData* layout = aInstStruct.iInst;
+	layout->iAttributes = aInstStruct.iAttribs; // transfer ownership
+	iLayouts.push_back(aInstStruct.iInst);
+	for(CZoomLevelNames::iterator pZoomLevel = aZoomLevelNames.begin(); pZoomLevel != aZoomLevelNames.end(); ++pZoomLevel)
+		{
+		auto_ptr<CMLCompDataInstOpt> p(new CMLCompDataInstOpt(*this, layout, aInstStruct.iInstName, pZoomLevel->second, pZoomLevel->first, aAllParams, aNonCompleteInstance));
+		CCompDatas& compDatas = iZoomLevelDatas[pZoomLevel->first];
+		compDatas.push_back(p.get());
+		p.release();
+		}
+	}
+
+void MLCompDataCdlInstanceOpt::Process()
+	{
+	for(CCompDataZoomLevelDatas::iterator pZoomLevel = iZoomLevelDatas.begin(); pZoomLevel != iZoomLevelDatas.end(); ++pZoomLevel)
+		{
+		CCompDatas& compDatas = pZoomLevel->second;
+		if(compDatas.size() == 0)
+			continue;
+		CMLCompDataInstOpt* firstInstOpt = compDatas[0];
+		cout << "processing instances for zoom level: " << firstInstOpt->ZoomName() << endl;
+
+		string firstInstName = firstInstOpt->Name();
+		for (CCompDatas::iterator pLayout = compDatas.begin(); pLayout != compDatas.end(); ++pLayout)
+			(*pLayout)->Process(firstInstName);
+		}
+	ProcessCommonImpl();
+	}
+
+void MLCompDataCdlInstanceOpt::WriteInstances()
+	{
+	bool found = false;
+	for(CCompDataZoomLevelDatas::iterator pZoomLevel = iZoomLevelDatas.begin(); pZoomLevel != iZoomLevelDatas.end(); ++pZoomLevel)
+		{
+		CCompDatas& compDatas = pZoomLevel->second;
+		if(!found && compDatas.size() > 0)
+			{
+			found = true;
+			cout << "writing instances ... " << endl;
+			}
+		for (CCompDatas::iterator pLayout = compDatas.begin(); pLayout != compDatas.end(); ++pLayout)
+			(*pLayout)->WriteInstance();
+		}
+	}
+
+CCdlTkInterface& MLCompDataCdlInstanceOpt::Interface()
+	{
+	return iInterface;
+	}
+
+const string KCommonImplStart = "\
+#include \"aknlayout2scalabledecode.h\"\n\
+namespace $NAMESPACENAME { extern TUint8 const KByteCodedData_$FIRSTINSTANCENAME[] = {\n";
+
+const string KCommonImplImpl = "\
+// $INDEX $COMMENT\n\
+$BYTES\n";
+
+void MLCompDataCdlInstanceOpt::ProcessCommonImpl()
+	{
+	// use the first instance name of the first zoom level
+	// it's not entirely accurate but it only needs to disambiguate
+	CCompDatas& compDatas = iZoomLevelDatas[EAknUiZoomNormal];
+	if(compDatas.size() == 0)
+		return;
+	CMLCompDataInstOpt* firstInstOpt = compDatas[0];
+
+	CdlTkUtil::CReplaceSet startImplSet;
+	startImplSet.Add("$NAMESPACENAME", iInterface.NamespaceName());
+	startImplSet.Add("$FIRSTINSTANCENAME", firstInstOpt->Name());
+	string bytecode = CdlTkUtil::MultiReplace(startImplSet, KCommonImplStart);
+	int byteCounter(0);
+
+	for (CMLCompDataInstOptImpls::iterator pImpl = iImpls.begin(); pImpl != iImpls.end(); ++pImpl)
+		{
+		vector<char>& bytes = (*pImpl)->iBytes;
+		if (!(*pImpl)->iIsRedirectedToExactCopy && bytes.size())
+			{
+			string byteString;
+			for (vector<char>::iterator pChar = bytes.begin(); pChar != bytes.end(); ++pChar)
+				{
+				CdlTkUtil::AppendString(byteString, CdlTkUtil::CharToHexString(*pChar));
+				CdlTkUtil::AppendString(byteString, KComma);
+				}
+
+			// in this case, we want to know the absolute index to help with debugging
+			int index = (*pImpl)->iByteCodeIndex;
+			if(byteCounter != index)
+				{
+				cerr << "Error: Data table mismatch for " << (*pImpl)->iName;
+				cerr << ": Bytecode index = " << CdlTkUtil::ShortToHexString(index);
+				cerr << "; byte counter = " << CdlTkUtil::ShortToHexString(byteCounter) << endl;
+				throw GeneralErr((*pImpl)->iName + " in interface " + iInterface.FileName());
+				}
+			byteCounter += bytes.size();
+
+			CdlTkUtil::CReplaceSet implSet;
+			implSet.Add("$INDEX", CdlTkUtil::IntToHexString(index));
+			implSet.Add("$COMMENT", (*pImpl)->iComment + (*pImpl)->iName + " (" + CdlTkUtil::ShortToHexString(bytes.size()) + " bytes)");
+			implSet.Add("$BYTES", byteString);
+			CdlTkUtil::AppendString(bytecode, CdlTkUtil::MultiReplace(implSet, KCommonImplImpl));
+			}
+		}
+	CdlTkUtil::AppendString(bytecode, "};\n}");
+	CCdlTkInstance& firstInst = firstInstOpt->Inst();
+	firstInst.SetExtraCpp(bytecode);
+	}
+
+int MLCompDataCdlInstanceOpt::FindSimilarBytes(CMLCompDataInstOptImpl* aImpl, int aBaseOffset)
+	{
+	int index = -1;
+	vector<char>::iterator startOfAddressableBlock = iBytesAggregated.begin() + aBaseOffset;
+	vector<char>::iterator found = std::search(
+		startOfAddressableBlock, 
+		iBytesAggregated.end(), 
+		aImpl->iBytes.begin(), 
+		aImpl->iBytes.end());
+	if(found != iBytesAggregated.end())
+		{
+		index = std::distance(iBytesAggregated.begin(), found); // we return the absolute position
+		}
+	return index;
+	}
+
+void MLCompDataCdlInstanceOpt::AddImpl(CMLCompDataInstOptImpl* aImpl)
+	{
+	if(!aImpl->iIsRedirectedToExactCopy)
+		{
+		CMLCompDataInstOptImpls::iterator found = std::find(iImpls.begin(), iImpls.end(), aImpl);
+		if(found == iImpls.end())
+			{
+			iImpls.push_back(aImpl);
+			}
+		else
+			{
+			cerr << "Error: " << aImpl->iName << " already added to byte stream" << endl;
+			throw GeneralErr(aImpl->iName + " in interface " + iInterface.FileName());
+			}
+		if (aImpl->iBytes.size())
+			{
+			aImpl->iByteCodeIndex = iBytesAggregated.size();
+			iBytesAggregated.insert(
+				iBytesAggregated.end(), 
+				aImpl->iBytes.begin(), 
+				aImpl->iBytes.end());
+			}
+		}
+	}
+
+int MLCompDataCdlInstanceOpt::ByteStreamSize() const
+	{
+	return iBytesAggregated.size();
+	}
+
+// end of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompData.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,1312 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+#include "MLCompData.h"
+#include "MLCompDataParse.h"
+#include "MLCompData2Cdl.h"
+#include "MLAttributes.h"
+
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+#include "Akndef.hrh"
+
+#include <set>
+#include <sstream>
+#include <iostream>
+#include <algorithm>
+
+
+//
+// const data
+//
+
+const string KCompDataPaneOutputOrder[] = {"C", "l", "t", "r", "b", "W", "H"};
+const string KCompDataPaneOutputOrderMirrored[] = {"C", "r", "t", "l", "b", "W", "H"};
+const int KCompDataPaneOutputOrderSize = ARRAY_LEN(KCompDataPaneOutputOrder);
+
+const string KCompDataGraphicOutputOrder[] = {"NumCols", "NumRows", "C", "l", "t", "r", "b", "W", "H"};
+const string KCompDataGraphicOutputOrderMirrored[] = {"NumCols", "NumRows", "C", "r", "t", "l", "b", "W", "H"};
+const int KCompDataGraphicOutputOrderSize = ARRAY_LEN(KCompDataGraphicOutputOrder);
+
+const string KCompDataTextOutputOrder[] = {"NumCols", "NumRows", "C", "l", "t", "r", "b", "W", "H", "J", "Font"};
+const string KCompDataTextOutputOrderMirrored[] = {"NumCols", "NumRows", "C", "r", "t", "l", "b", "W", "H", "J", "Font"};
+const int KCompDataTextOutputOrderSize = ARRAY_LEN(KCompDataTextOutputOrder);
+
+const string KCompDataKeywordParamHeight = "H";
+const string KCompDataKeywordParamType = "Type";
+const string KCompDataKeywordParamFont = "Font";
+const string KCompDataKeywordParamNumCols = "NumCols";
+const string KCompDataKeywordParamNumRows = "NumRows";
+const string KCompDataKeywordScreenContents = "Screen Contents";
+
+const string KCompDataKeywordUnderscore = "_";
+const string KCompDataKeywordLineNameSuffixGraphic = "g";
+const string KCompDataKeywordLineNameSuffixText = "t";
+
+const string KCompDataSearchCollectionNumeric = "0123456789";
+const string KCompDataBadValue = "Bad Value";
+const string KCompDataLayoutEmpty = "ELayoutEmpty";
+const string KCompDataUnknown = "unknown";
+
+const string KCompDataCellNameLeft("l");
+const string KCompDataCellNameRight("r");
+const string KCompDataCellNameJustification("J");
+
+const string KAttributeNameStyle1 = "style_1";
+const string KAttributeNameStyle2 = "style_2";
+const string KAttributeNameStyle3 = "style_3";
+const string KAttributeNameStyle1Plain = "plain";
+const string KAttributeNameStyle1Bold = "bold";
+const string KAttributeNameStyle3Outline = "outline";
+
+const string KAttributeNameNumberOfColumns = "Number_of_columns";
+const string KAttributeNameNumberOfRows = "Number_of_rows";
+const string KAttributeNameNumberOfRowsColsAuto = "AUTO";
+
+
+//
+// TMLCompDataValues
+//
+
+TMLCompDataValues::TMLCompDataValues()
+	: 
+	iLine(NULL), 
+	iName(KCompDataBadValue)
+	{
+	}
+
+TMLCompDataValues::TMLCompDataValues(TMLCompDataLine* aLine)
+	: 
+	iLine(aLine), 
+	iName(aLine->iName)
+	{
+	}
+
+bool TMLCompDataValues::operator==(const TMLCompDataValues& aOther) const
+	{
+	typedef const map<int, TMLCompDataZoomLevels> TBase;
+	bool eq =
+		iName == aOther.iName &&
+		(*static_cast<TBase*>(this) == aOther);
+	return eq;
+	}
+
+TMLCompDataValues::~TMLCompDataValues()
+	{
+	}
+
+bool TMLCompDataValues::Merge(TMLCompDataLine* aLine, string aName, TMLCompDataValues& aOtherValues, bool aMirrorMerge)
+	{
+	iLine = aLine;
+	iName = aName; // we may be swapping l and r
+
+	// create missing values in this line if needed
+	for (iterator pOtherVal=aOtherValues.begin(); pOtherVal!=aOtherValues.end(); ++pOtherVal)
+		{
+		TMLCompDataZoomLevels& otherZoomLevels = pOtherVal->second;
+		TMLCompDataZoomLevels& thisZoomLevels = (*this)[pOtherVal->first];
+		thisZoomLevels = otherZoomLevels; // we want exactly the correct number of calcs from the other cell
+		if(aMirrorMerge)
+			{
+			if(iName == KCompDataCellNameJustification)
+				{
+				// reverse the justification
+				for(TMLCompDataZoomLevels::iterator pCalcs = thisZoomLevels.begin(); pCalcs != thisZoomLevels.end(); ++pCalcs)
+					{
+					TMLCompDataCalcs& calcs = pCalcs->second;
+					for(TMLCompDataCalcs::iterator pVal = calcs.begin(); pVal != calcs.end(); ++pVal)
+						pVal->second = MirrorJustificationValue(pVal->second);
+					}
+				}
+			}
+		}
+	return true;
+	}
+
+const string KParamLimitNames[] = { "NumCols", "NumRows" };
+const string KHorizNames[] = { "l", "r", "W" };
+const string KVertNames[] = { "t", "b", "H", "Font" };
+const set<string> KParamLimitNamesSet(KParamLimitNames, ARRAY_END(KParamLimitNames));
+const set<string> KHorizNamesSet(KHorizNames, ARRAY_END(KHorizNames));
+const set<string> KVertNamesSet(KVertNames, ARRAY_END(KVertNames));
+
+TMLCompDataValues::TCompDataCellType TMLCompDataValues::Type(string aName)
+	{
+	TMLCompDataValues::TCompDataCellType type;
+	if(KParamLimitNamesSet.find(aName) != KParamLimitNamesSet.end())
+		{
+		type = TMLCompDataValues::ECellTypeParamLimit;	
+		}
+	else if(KHorizNamesSet.find(aName) != KHorizNamesSet.end())
+		{
+		type = TMLCompDataValues::ECellTypeCol;
+		}
+	else if(KVertNamesSet.find(aName) != KVertNamesSet.end())
+		{
+		type = TMLCompDataValues::ECellTypeRow;
+		}
+	else
+		{
+		type = TMLCompDataValues::ECellTypeDefault;
+		}
+	return type;
+	}
+
+
+string TMLCompDataValues::MirrorJustificationValue(const string& aValue)
+	{
+	int val = CdlTkUtil::ParseInt(aValue);
+	if(val == ELayoutAlignLeft)
+		val = ELayoutAlignRight;
+	else if(val == ELayoutAlignRight)
+		val = ELayoutAlignLeft;
+	return CdlTkUtil::IntToString(val);
+	}
+
+
+void TMLCompDataValues::Compile(const string& aCellName)
+	{
+	// ensure that missing varieties are filled with null values
+	// we assume that each variety is present in all zoom levels that are defined
+	if(iLine) // screen contents isn't contained in a line
+		{
+		int thisSize = size();
+		int numVarieties = iLine->MaxVariety() + 1; // get zero based index
+		int maximum = max(numVarieties, thisSize);
+		int maxMulti;
+		switch(TMLCompDataValues::Type(aCellName))
+			{
+			case ECellTypeCol:
+				maxMulti = iLine->NumCols();
+				break;
+			case ECellTypeRow:
+				maxMulti = iLine->NumRows();
+				break;
+			default:
+				maxMulti = 1;
+				break;
+			}
+		for(int ii = 0; ii < maximum; ii++)
+			{
+			// operator[] fills in missing values
+			TMLCompDataZoomLevels& zoomLevels = (*this)[ii];
+			for(TMLCompDataZoomLevels::iterator pCalcs = zoomLevels.begin(); pCalcs != zoomLevels.end(); ++pCalcs)
+				{
+				TMLCompDataCalcs& calcs = pCalcs->second;
+				if(ii < numVarieties)
+					{
+					if(calcs.size() > maxMulti)
+                        {
+                        // Handle the case where data from a merged instance has too many calcs
+                        TMLCompDataCalcs::iterator start = calcs.find(maxMulti);
+                        TMLCompDataCalcs::iterator end = calcs.end();
+                        calcs.erase(start, end);
+                        }
+					}
+				else
+					{
+					// get rid of varieties from instances that we have merged onto
+					calcs.clear();			
+					}
+				}
+			}
+		}
+	}
+
+string TMLCompDataValues::CppValue(const string& aValue)
+	{
+	if (aValue.size())
+		return aValue;
+	else
+		return KCompDataLayoutEmpty;
+	}
+
+//
+// TMLCompDataParentInfoSelector
+//
+TMLCompDataParentInfoSelector::TMLCompDataParentInfoSelector()
+	{
+
+	}
+
+TMLCompDataParentInfoSelector::TMLCompDataParentInfoSelector(int aParentId, int aParentVariety)
+	:
+	iParentId(aParentId),
+	iParentVariety(aParentVariety)
+	{
+
+	}
+
+//
+//  TMLCompDataParentInfo
+//
+
+TMLCompDataParentInfo::TMLCompDataParentInfo()
+	:
+	iLine(0)
+	{
+
+	}
+
+TMLCompDataParentInfo::TMLCompDataParentInfo(TMLCompDataLine* aLine)
+	:
+	iLine(aLine)
+	{
+
+	}
+
+TMLCompDataParentInfo::~TMLCompDataParentInfo()
+	{
+
+	}
+
+void TMLCompDataParentInfo::Merge(const TMLCompDataParentInfo& aOther)
+	{
+	for (const_iterator pOtherVariety = aOther.begin(); pOtherVariety != aOther.end(); ++pOtherVariety)
+		{
+		int varietyIndex = pOtherVariety->first;
+		const TMLCompDataParentInfoSelector& selector = pOtherVariety->second;
+		insert(make_pair(varietyIndex, selector));
+		}
+	}
+
+//
+//  TMLCompDataLine
+//
+
+TMLCompDataLine::TMLCompDataLine()
+:	iId(0),
+	iIsUnique(true), 
+	iIsMirroredHorizontally(false),
+	iType(EUnknownComponent),
+	iName(KCompDataUnknown),
+	iDrawingOrder(-1),
+	iMaxVariety(0),
+	iParentTable(0),
+	iParentInfo(0),
+	iAttributeInfo(0),
+	iNumCols(1),
+	iNumRows(1),
+	iNeedsOptions(false),
+	iNeedsCols(false),
+	iNeedsRows(false),
+	iGlobalIndex(0)
+	{	
+		
+	}
+
+TMLCompDataLine::TMLCompDataLine(const TMLCompDataLine& aOther)
+	{
+	if(this == &aOther)
+		return;
+	*this = aOther; // this will take a copy of the owning pointer
+	if(aOther.iParentInfo) // if it wasn't zero
+		iParentInfo = new TMLCompDataParentInfo(*(aOther.iParentInfo)); // we don't want to take ownership, so make our own copy
+	if(aOther.iAttributeInfo) // if it wasn't zero
+		iAttributeInfo = new TMLCompDataAttributeInfo(*(aOther.iAttributeInfo)); // we don't want to take ownership, so make our own copy
+
+	for (iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		TMLCompDataValues& val = pVal->second;
+		val.iLine = this;
+		}
+	iParentTable = 0; // will be set during compile
+	}
+
+bool TMLCompDataLine::operator==(const TMLCompDataLine& aOther) const
+	{
+	return (Name() == aOther.Name()) && ValuesEqual(aOther);
+	}
+
+TMLCompDataLine::~TMLCompDataLine()
+	{
+	delete iParentInfo;
+	delete iAttributeInfo;
+	}
+
+bool TMLCompDataLine::lessthan(TMLCompDataLine* aLeft, TMLCompDataLine* aRight)
+	{
+	string pureNameLeft = aLeft->NameDiscountingSuffix();
+	string pureNameRight = aRight->NameDiscountingSuffix();
+	if(pureNameLeft != pureNameRight)
+		{
+		return (aLeft->iName) < (aRight->iName);
+		}
+	else
+		{
+		int left = CdlTkUtil::ParseInt(aLeft->NameSuffix());
+		int right = CdlTkUtil::ParseInt(aRight->NameSuffix());
+		return left < right;
+		}
+	}
+
+bool TMLCompDataLine::ValuesEqual(const TMLCompDataLine& aOther) const
+	{
+	bool eq = true;
+	const_iterator pVal, pOther;
+	for (pVal = begin(), pOther = aOther.begin(); 
+		 eq && pVal != end() && pOther != aOther.end(); 
+		 ++pVal, ++pOther)
+		{
+		eq = (*pVal == *pOther);
+		}
+	eq = eq && pVal == end() && pOther == aOther.end();
+	return eq;
+	}
+
+string TMLCompDataLine::Name() const
+	{
+	return iName;
+	}
+
+bool TMLCompDataLine::Merge(TMLCompDataLine& aOtherLine)
+	{
+	bool compatible = 
+		(iId == aOtherLine.iId) ||
+		(iName == aOtherLine.iName) ||
+		(iType == aOtherLine.iType);
+	if(compatible)
+		{
+		iDrawingOrder = aOtherLine.iDrawingOrder;
+		iMaxVariety = aOtherLine.iMaxVariety;
+		iIsMirroredHorizontally |= aOtherLine.iIsMirroredHorizontally; // in the case of an elaf layout merging onto an abrw layout, the chirality will be preserved
+		iNeedsOptions |= aOtherLine.iNeedsOptions;
+
+		if(!iParentInfo)
+			{
+			// must be screen...
+			iParentInfo = new TMLCompDataParentInfo();
+			}
+		if(aOtherLine.iParentInfo)
+			{
+			iParentInfo->Merge(*(aOtherLine.iParentInfo));
+			}
+
+		if(!iAttributeInfo)
+			{
+			// must be screen...
+			iAttributeInfo = new TMLCompDataAttributeInfo();
+			}
+		if(aOtherLine.iAttributeInfo)
+			{
+			iAttributeInfo->Merge(*(aOtherLine.iAttributeInfo));
+			}
+
+		// for the API, we need to know if there are any multi-value components in either orientation
+		iNeedsCols = iNeedsCols || aOtherLine.iNeedsCols;
+		iNeedsRows = iNeedsRows || aOtherLine.iNeedsRows;
+		// however, we want exactly the correct number of calcs from the other cell
+		iNumCols = aOtherLine.iNumCols;
+		iNumRows = aOtherLine.iNumRows;
+
+		// if this line has no values, then we must do a mirror merge
+		bool mirrorMerge = empty() && iIsMirroredHorizontally;
+
+		// create missing values in this line if needed
+		for (TMLCompDataLine::iterator pOtherValues=aOtherLine.begin(); pOtherValues!=aOtherLine.end(); ++pOtherValues)
+			{
+			string index = pOtherValues->first;
+			if(mirrorMerge)
+				{
+				// flip left and right
+				if(index == KCompDataCellNameLeft)
+					index = KCompDataCellNameRight;
+				else if(index == KCompDataCellNameRight)
+					index = KCompDataCellNameLeft;
+				}
+
+			(*this)[index].Merge(this, index, pOtherValues->second, mirrorMerge);
+			}
+		}
+	return compatible;
+	}
+
+TMLAttributeZoomLevels* TMLCompDataLine::GetAttributeZoomLevels(string aAttribName, int aVariety)
+	{
+	TMLAttributeZoomLevels* found = 0;
+	TMLCompData& data = *(iParentTable->iTables);
+	TMLAttributes& attributes = *(data.iAttributes);
+	int attribId = attributes.iNames[aAttribName];
+	if(attribId == 0)
+		throw GeneralErr(string("Attribute name not found: ") + aAttribName);
+	// find out from attribute info which attribute set we need
+	// but if there is none specified, we don't need to search
+	if(iAttributeInfo)
+		{
+		TMLCompDataAttributeInfoSelector& selector = (*iAttributeInfo)[aVariety];
+		// go to parent straight away, as parent always stores attribute data for its children
+		found = GetParentAttributeZoomLevels(selector.iAttributeSetName, attribId, aVariety);
+		}
+	return found;
+	}
+
+TMLAttributeZoomLevels* TMLCompDataLine::GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety)
+	{
+	TMLAttributeZoomLevels* found = NULL;
+	TMLCompDataParentInfo::iterator pFoundSelector = iParentInfo->find(aVariety);
+	if(pFoundSelector != iParentInfo->end())
+		{
+		const TMLCompDataParentInfoSelector& parentInfoSelector = pFoundSelector->second;
+		if(iParentTable && iParentTable->iParentLine)
+			{
+			found = iParentTable->iParentLine->FindAttributeZoomLevels(aAttribSetName, aAttribId);
+			if(!found)
+				{
+				// recurse to next parent container
+				int variety = parentInfoSelector.iParentVariety;
+				iParentTable->iParentLine->GetParentAttributeZoomLevels(aAttribSetName, aAttribId, variety);
+				}
+			}
+		}
+	return found;
+	}
+
+TMLAttributeZoomLevels* TMLCompDataLine::FindAttributeZoomLevels(string aAttribSetName, int aAttribId)
+	{
+	TMLCompData& data = *(iParentTable->iTables);
+	TMLAttributes& attributes = *(data.iAttributes);
+	int id = iId;
+	TMLAttributes::iterator foundAttributeSetComponent = attributes.find(id);
+	if(foundAttributeSetComponent != attributes.end())
+		{
+		TMLAttributeSetComponent& component = foundAttributeSetComponent->second;
+		TMLAttributeSet* pSet = component[aAttribSetName];
+		if(pSet)
+			{
+			TMLAttributeSet& attributeSet = *pSet;
+			TMLAttributeSet::iterator foundAttrib = attributeSet.find(aAttribId);
+			if(foundAttrib != attributeSet.end())
+				{
+				return &(foundAttrib->second);
+				}
+			}
+		}
+	return NULL;
+	}
+
+void TMLCompDataLine::Compile()
+	{
+	// compile values
+	for(iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		(pVal->second).Compile(pVal->first);
+		}
+	CompileParamLimits(TMLCompDataValues::ECellTypeCol, KCompDataKeywordParamNumCols);
+	CompileParamLimits(TMLCompDataValues::ECellTypeRow, KCompDataKeywordParamNumRows);
+	CompileFontHeights();
+	}
+
+void TMLCompDataLine::CompileParamLimits(TMLCompDataValues::TCompDataCellType aParamLimitType, const string& aParamLimitCellName)
+	{
+	TMLCompDataValues paramLimits(this);
+
+	for(iterator pValues = begin(); pValues != end(); ++pValues)
+		{
+		string cellName = pValues->first;
+		if(TMLCompDataValues::Type(cellName) == aParamLimitType)
+			{
+			// calculate the param limits for this cell
+			TMLCompDataValues& values = pValues->second;
+			for(TMLCompDataValues::iterator pZoomLevels = values.begin(); pZoomLevels != values.end(); ++pZoomLevels)
+				{
+				int nextVariety = pZoomLevels->first;
+				TMLCompDataZoomLevels& zoomLevels = pZoomLevels->second;
+				TMLCompDataZoomLevels& paramLimitsZoomLevels = paramLimits[nextVariety];
+				for(TMLCompDataZoomLevels::iterator pCalcs = zoomLevels.begin(); pCalcs != zoomLevels.end(); ++pCalcs)
+					{
+					// accumulate the largest size of calc into the param limit
+					int zoomLevel = pCalcs->first;
+					int nextParamLimit = pCalcs->second.size();
+					TMLCompDataCalcs& paramLimitCalcs = paramLimitsZoomLevels[zoomLevel];
+					string& paramLimit = paramLimitCalcs[0];
+					int currentParamLimit = CdlTkUtil::ParseInt(paramLimit);
+					if(nextParamLimit > currentParamLimit)
+						paramLimit = CdlTkUtil::IntToString(nextParamLimit);
+					}
+				if(!paramLimitsZoomLevels.size())
+					{
+					// there were no defined values for this variety, but we know we'll
+					// insert an empty value at least
+					TMLCompDataCalcs& paramLimitCalcs = paramLimitsZoomLevels[EAknUiZoomNormal];
+					paramLimitCalcs.insert(make_pair(0, CdlTkUtil::IntToString(1)));
+					}
+				}
+			}
+		}
+	insert(make_pair(aParamLimitCellName, paramLimits));
+	}
+
+void TMLCompDataLine::CompileFontHeights()
+	{
+	if(iType == ETextComponent)
+		{
+		TMLCompDataValues font(this);
+
+		TMLCompDataValues types = (*this)[KCompDataKeywordParamType];
+		TMLCompDataValues heights = (*this)[KCompDataKeywordParamHeight];
+		
+		// note that these are the number of varieties, there may be zoom level and then rows inside
+		int numTypeVarieties = types.size();
+		int numHeightVarieties = heights.size();
+
+		for(TMLCompDataValues::iterator pZoomLevels = heights.begin(); pZoomLevels != heights.end(); ++pZoomLevels)
+			{
+			int nextVariety = pZoomLevels->first;
+			TMLAttributeZoomLevels* style1ZoomLevels = GetAttributeZoomLevels(KAttributeNameStyle1, nextVariety);
+			TMLAttributeZoomLevels* style3ZoomLevels = GetAttributeZoomLevels(KAttributeNameStyle3, nextVariety);
+			TMLCompDataZoomLevels& heightsZoomLevels = pZoomLevels->second;
+			TMLCompDataZoomLevels& typesZoomLevels = types[nextVariety];
+			TMLCompDataZoomLevels& fontZoomLevels = font[nextVariety];
+			
+			for(TMLCompDataZoomLevels::iterator pHeightCalcs = heightsZoomLevels.begin(); pHeightCalcs != heightsZoomLevels.end(); ++pHeightCalcs)
+				{
+				// if the types don't have zoom data, fall back to normal zoom
+				int zoomIndex = pHeightCalcs->first;
+				int numTypesZoomLevels = typesZoomLevels.size();
+				int typeZoomIndex = numTypesZoomLevels > 1 ? zoomIndex : EAknUiZoomNormal; 
+				TMLCompDataCalcs& typeCalcs = typesZoomLevels[typeZoomIndex];
+
+				// get attribute data
+				int outline = 0;
+				int posture = 0;
+				int weight =  0;
+				if(style1ZoomLevels)
+					{
+					string style1 = (*style1ZoomLevels)[pHeightCalcs->first];
+					if(style1 == KAttributeNameStyle1Bold)
+						weight = 1;
+					}
+				if(style3ZoomLevels)
+					{
+					string style3 = (*style3ZoomLevels)[pHeightCalcs->first];
+					if(style3 == KAttributeNameStyle3Outline)
+						outline = 1;
+					}
+
+				// we want to have a font id for each height, even if the spec
+				// has not specified the type each time
+				TMLCompDataCalcs& fontCalcs = fontZoomLevels[pHeightCalcs->first];
+				TMLCompDataCalcs& next = pHeightCalcs->second;
+				for(TMLCompDataCalcs::iterator pHeightCalc = next.begin(); pHeightCalc != next.end(); ++pHeightCalc)
+					{
+					// for undefined type, let font provider use default, 
+					// and always choose the first type for a multi value item
+					int calcIndex = pHeightCalc->first;
+					int type = numTypeVarieties > 0 ? CdlTkUtil::ParseInt(typeCalcs[0]) : ELayoutCompilerFontCategoryUndefined;
+					int height = numHeightVarieties > 0 ? CdlTkUtil::ParseInt(pHeightCalc->second) : 0; 
+					int fontId = EncodeFontId(height, outline, posture, weight, type);
+					fontCalcs[calcIndex] = CdlTkUtil::IntToString(fontId);
+					}
+				}
+			}
+		insert(make_pair(string(KCompDataKeywordParamFont), font));
+		}
+	}
+
+int TMLCompDataLine::EncodeFontId(int aHeight, int aOutline, int aPosture, int aWeight, int aCategory) const
+	{
+	//
+	// 31           |                           30 - 21                               |          20 - 07                |     06      |     05      |      04      |      03 - 00
+	// encoded |                text pane height 0-1023               |        <not used>           |  outline |  posture |  weight   |      category              
+
+    int encodedMasked = 1 << 31;
+    int heightMasked = aHeight << 21;
+
+	int outlineMasked = aOutline << 6;
+	int postureMasked = aPosture << 5;
+	int weightMasked = aWeight << 4;
+    int categoryMasked = aCategory;
+
+    return(encodedMasked | heightMasked | outlineMasked | postureMasked | weightMasked | categoryMasked);
+	}
+
+bool TMLCompDataLine::MatchParams(const TMLCompDataLine& aLine) const
+	{
+	if (NeedsOptions() != aLine.NeedsOptions())
+		return false;
+	if (NeedsCols() != aLine.NeedsCols())
+		return false;
+	if (NeedsRows() != aLine.NeedsRows())
+		return false;
+	return true;
+	}
+
+bool TMLCompDataLine::MatchNameDiscountingSuffix(const TMLCompDataLine& aLine) const
+	{
+	// we are trying to compare whether the names are the same apart from a trailing number
+	string pureName = NameDiscountingSuffix();
+	string pureNameOther = aLine.NameDiscountingSuffix();
+	string ending = pureName.substr(pureName.find_last_not_of(KCompDataKeywordUnderscore));
+
+	bool namesMatch = (pureName == pureNameOther);
+	bool correctEnding = (ending == KCompDataKeywordLineNameSuffixGraphic || ending == KCompDataKeywordLineNameSuffixText);
+	return (namesMatch && correctEnding);
+	}
+
+bool TMLCompDataLine::MatchType(const TMLCompDataLine& aLine) const
+	{
+	// first check that the type is equivalent
+	bool equivalent = false;
+	switch(iType)
+		{
+		case ETextComponent:
+			{
+			if(aLine.iType == ETextComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		case EScreenComponent:
+		case EContainerComponent:
+		case EPaneComponent:
+		case EGraphicComponent:
+			{
+			if(aLine.iType == EScreenComponent
+				|| aLine.iType == EContainerComponent
+				|| aLine.iType == EPaneComponent
+				|| aLine.iType == EGraphicComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		case EUnknownComponent:
+		default:
+			{
+			if(aLine.iType == EUnknownComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		}
+
+	return equivalent;
+	}
+
+string TMLCompDataLine::NameDiscountingSuffix() const
+	{
+	int lastNonNumericPos = iName.find_last_not_of(KCompDataSearchCollectionNumeric);
+	int length = lastNonNumericPos + 1;
+	return iName.substr(0, length);
+	}
+
+string TMLCompDataLine::NameSuffix() const
+	{
+	int lastNonNumericPos = iName.find_last_not_of(KCompDataSearchCollectionNumeric);
+	int suffixPos = lastNonNumericPos + 1;
+	return iName.substr(suffixPos);
+	}
+
+bool TMLCompDataLine::NeedsParams() const 
+	{ 
+	return iNeedsOptions || iNeedsCols || iNeedsRows; 
+	}
+
+bool TMLCompDataLine::NeedsOptions() const 
+	{
+	return iNeedsOptions; 
+	}
+
+bool TMLCompDataLine::NeedsCols() const 
+	{
+	return iNeedsCols; 
+	}
+
+bool TMLCompDataLine::NeedsRows() const 
+	{
+	return iNeedsRows; 
+	}
+
+int TMLCompDataLine::MaxVariety() const
+	{
+	return iMaxVariety;
+	}
+
+int TMLCompDataLine::NumCols() const
+	{
+	return iNumCols;
+	}
+
+int TMLCompDataLine::NumRows() const
+	{
+	return iNumRows;
+	}
+
+
+void TMLCompDataLine::SetMaxVariety(int aMaxVariety)
+	{
+	iMaxVariety = aMaxVariety;
+	if(iMaxVariety > 0) // zero based
+		iNeedsOptions = true;
+	}
+
+void TMLCompDataLine::SetNumCols(int aNumCols)
+	{
+	iNumCols = aNumCols;
+	if(iNumCols > 1)
+		iNeedsCols = true;
+	}
+
+void TMLCompDataLine::SetNumRows(int aNumRows)
+	{
+	iNumRows = aNumRows;
+	if(iNumRows > 1)
+		iNeedsRows = true;
+	}
+
+void TMLCompDataLine::SetNeedsCols(bool aNeeds)
+    {
+    iNeedsCols = aNeeds;    
+    }
+
+void TMLCompDataLine::SetNeedsRows(bool aNeeds)
+    {
+    iNeedsRows = aNeeds;
+    }
+
+//
+// TMLCompDataAttributeInfoSelector
+//
+TMLCompDataAttributeInfoSelector::TMLCompDataAttributeInfoSelector()
+	{
+
+	}
+
+TMLCompDataAttributeInfoSelector::TMLCompDataAttributeInfoSelector(string aAttributeSetName)
+	:
+	iAttributeSetName(aAttributeSetName)
+	{
+
+	}
+
+//
+//  TMLCompDataAttributeInfo
+//
+
+TMLCompDataAttributeInfo::TMLCompDataAttributeInfo()
+	:
+	iLine(0)
+	{
+
+	}
+
+TMLCompDataAttributeInfo::TMLCompDataAttributeInfo(TMLCompDataLine* aLine)
+	:
+	iLine(aLine)
+	{
+
+	}
+
+TMLCompDataAttributeInfo::~TMLCompDataAttributeInfo()
+	{
+
+	}
+
+void TMLCompDataAttributeInfo::Merge(const TMLCompDataAttributeInfo& aOther)
+	{
+	for (const_iterator pOtherVariety = aOther.begin(); pOtherVariety != aOther.end(); ++pOtherVariety)
+		{
+		int varietyIndex = pOtherVariety->first;
+		const TMLCompDataAttributeInfoSelector& selector = pOtherVariety->second;
+		insert(make_pair(varietyIndex, selector));
+		}
+	}
+
+
+
+//
+// TMLCompDataTable::TMLCompDataSubTable
+//
+
+bool TMLCompDataTable::TMLCompDataSubTable::NeedsParams() const 
+	{ 
+	return iNeedsOption || iNeedsCol || iNeedsRow; 
+	}
+
+
+//
+// TMLCompDataTable
+//
+
+TMLCompDataTable::TMLCompDataTable(TMLCompData* aTables)
+	: 
+	iTables(aTables), 
+	iParentLine(NULL), 
+	iFirstLineGlobalIndex(-1), 
+	iAppend(false),
+	iId(0),
+	iNeedsP(false),
+	iNeedsIndex(false)
+	{
+	}
+
+TMLCompDataTable::TMLCompDataTable(TMLCompData* aTables, const TMLCompDataTable& aOther)
+	: 
+	iTables(aTables), 
+	iParentLine(NULL), 
+	iFirstLineGlobalIndex(aOther.iFirstLineGlobalIndex), 
+	iAppend(aOther.iAppend), iColumnNames(aOther.iColumnNames), iName(aOther.iName),
+	iParentName(aOther.iParentName),
+  	iId(aOther.iId)
+	{
+	for (const_iterator pLine = aOther.begin(); pLine != aOther.end(); ++pLine)
+		push_back(new TMLCompDataLine(**pLine));
+	}
+
+TMLCompDataTable::~TMLCompDataTable()
+	{
+	for (iterator pLine = begin(); pLine != end(); ++pLine)
+		delete *pLine;
+	}
+
+bool TMLCompDataTable::lessthan(TMLCompDataTable* aLeft, TMLCompDataTable* aRight)
+	{
+	return (aLeft->iId) < (aRight->iId);
+	}
+
+string TMLCompDataTable::Name()
+	{
+	return iName;
+	}
+
+TMLCompDataLine* TMLCompDataTable::FindLine(const string& aName)
+	{
+	for (iterator pLine = begin(); pLine != end(); ++pLine)
+		{
+		TMLCompDataLine& line = **pLine;
+		string paramLimitsName = MLCompDataToCdl::LineParamLimitsApiName(line);
+		// first check the lines for a direct match
+		// then try the param limits instead
+		if (line.Name() == aName || 
+			(line.NeedsParams() && paramLimitsName == aName))
+			return *pLine;
+		}
+	return 0;
+	}
+
+TMLCompDataTable::TMLCompDataSubTable* TMLCompDataTable::FindSubTable(const string& aName)
+	{
+	for(TMLCompDataSubTables::iterator pSub = iSubTables.begin(); pSub != iSubTables.end(); ++pSub)
+		{
+		TMLCompDataSubTable& sub = **pSub;
+		string subTableName = MLCompDataToCdl::SubTableApiName(sub);
+		string subTableLimitsName = MLCompDataToCdl::SubTableLimitsApiName(sub);
+		string paramLimitsName = MLCompDataToCdl::SubTableParamLimtsApiName(sub);
+		TMLCompDataLine& line = *((*this)[0]);
+		// first check the lines for a direct match
+		// then try the param limits instead
+		if (subTableName == aName ||
+			subTableLimitsName == aName ||
+			(sub.NeedsParams() && paramLimitsName == aName)) // need to check whether the subtable needs params
+			return &sub;
+		}
+	return 0;
+	}
+
+void TMLCompDataTable::Merge(TMLCompDataTable& aOther)
+	{
+	for (iterator pOtherLine = aOther.begin(); pOtherLine != aOther.end(); )
+		{
+        TMLCompDataLine* found = FindLine((*pOtherLine)->Name());
+        if(found)
+            {
+            found->Merge(**pOtherLine);
+            delete *pOtherLine;
+			pOtherLine = aOther.erase(pOtherLine);
+			}
+		else
+            {
+			push_back(*pOtherLine);
+			(*pOtherLine)->iParentTable = this;
+			pOtherLine = aOther.erase(pOtherLine);
+			}
+		}
+	}
+
+
+void TMLCompDataTable::Compile()
+	{
+	SetDefaultColumnNames();
+	sort(begin(), end(), TMLCompDataLine::lessthan);	
+
+	iNeedsIndex = false;
+	iNeedsP = false;
+	for (iterator pLine = begin(); pLine != end(); ++pLine)
+		{
+		(*pLine)->Compile();
+		}
+	BuildSubTables();
+	NormalizeSubTables();
+	}
+
+void TMLCompDataTable::BuildSubTables()
+	{
+	DestroySubTables();
+
+	int count = size();
+	if(count > 0)
+		{
+		TMLCompDataSubTable* subTable = 0;
+		for (int i=0; i<count; i++)
+			{
+			TMLCompDataLine& line = *(*this)[i];
+			if (subTable)
+				{
+				TMLCompDataLine* firstLine = (*this)[(*subTable)[0]];
+				if (firstLine->NameSuffix() == "1" && firstLine->MatchNameDiscountingSuffix(line) && firstLine->MatchType(line))
+					{
+					subTable->iName = line.NameDiscountingSuffix();
+					}
+				else // only terminate the subtable if the lines don't match, or if the first line isn't numbered "1"
+					{
+					if (subTable->size() > 1)
+						iSubTables.push_back(subTable);
+					else
+						delete subTable;
+					subTable = new TMLCompDataSubTable;
+					}
+				}
+			else
+				{
+				subTable = new TMLCompDataSubTable;
+				}
+			subTable->iNeedsOption |= line.NeedsOptions();
+			subTable->iNeedsCol |= line.NeedsCols();
+			subTable->iNeedsRow |= line.NeedsRows();
+			subTable->push_back(i);
+			}
+
+		if (subTable->size() > 1) 
+			{
+			iSubTables.push_back(subTable);
+			}
+		else
+			delete subTable;
+		}
+	}
+
+void TMLCompDataTable::NormalizeSubTables()
+	{
+	for(TMLCompDataSubTables::iterator pSub = iSubTables.begin(); pSub != iSubTables.end(); ++pSub)
+		{
+		TMLCompDataSubTable& sub = **pSub;
+		for(TMLCompDataSubTable::iterator pLineId = sub.begin(); pLineId != sub.end(); ++pLineId)
+			{
+			TMLCompDataLine& line = *((*this)[*pLineId]);
+
+			line.iNeedsOptions |= sub.iNeedsOption;
+			line.iNeedsCols |= sub.iNeedsCol;
+			line.iNeedsRows |= sub.iNeedsRow;
+			}
+		}
+	}
+
+
+void TMLCompDataTable::DestroySubTables()
+	{
+	for (TMLCompDataSubTables::iterator pSub = iSubTables.begin(); pSub != iSubTables.end(); ++pSub)
+		delete *pSub;
+	iSubTables.clear();
+	}
+
+
+const string KValueNames[] = { "Font", "C", "l", "r", "W", "J", "t", "r", "b", "H" };
+const set<string> KValueNamesSet(KValueNames, ARRAY_END(KValueNames));
+
+bool TMLCompDataTable::IsValueColumn(string aName)
+	{
+	return KValueNamesSet.find(aName) != KValueNamesSet.end();
+	}
+
+const string KNumericNames[] = { "C", "l", "r", "W", "t", "r", "b", "H" };
+const set<string> KNumericNamesSet(KNumericNames, ARRAY_END(KNumericNames));
+
+bool TMLCompDataTable::IsNumericColumn(string aName)
+	{
+	return KNumericNamesSet.find(aName) != KNumericNamesSet.end();
+	}
+
+const string KHorizontalColumnNames[] = { "l", "r", "W"};
+const set<string> KHorizontalNamesSet(KHorizontalColumnNames, ARRAY_END(KHorizontalColumnNames));
+
+bool TMLCompDataTable::IsHorizontalColumn(string aName)
+	{
+	return KHorizontalNamesSet.find(aName) != KHorizontalNamesSet.end();
+	}
+
+const string KVerticalColumnNames[] = {"t", "b", "H" };
+const set<string> KVerticalNamesSet(KVerticalColumnNames, ARRAY_END(KVerticalColumnNames));
+
+bool TMLCompDataTable::IsVerticalColumn(string aName)
+	{
+	return KVerticalNamesSet.find(aName) != KVerticalNamesSet.end();
+	}
+
+
+const string KPaneColumnNames[] = {"Item", "C", "l", "t", "r", "b", "W", "H", "Remarks"};
+const string KGraphicColumnNames[] = {"Item", "C", "l", "t", "r", "b", "W", "H", "Remarks"};
+const string KTextColumnNames[] = {"Font", "C", "l", "r", "t", "b", "W", "H", "J", "Remarks"};
+
+void TMLCompDataTable::SetDefaultColumnNames()
+	{
+	iColumnNames.clear();
+	iColumnNames.insert(iColumnNames.end(), KPaneColumnNames, ARRAY_END(KTextColumnNames)); // superset
+	}
+
+TMLCompDataTable::TMLCompDataSubTable::TMLCompDataSubTable()
+: 
+	iNeedsOption(false),
+	iNeedsCol(false),
+	iNeedsRow(false)
+	{
+	}
+
+
+//
+// TMLCompData
+//
+
+TMLCompData::TMLCompData()
+	: 
+	iCanBeMirror(false),
+	iIsBaseInstance(false),
+	iAttributes(0)
+	{
+	}
+
+TMLCompData::TMLCompData(const TMLCompData& aOther)
+	{
+	*this = aOther;
+	}
+
+TMLCompData& TMLCompData::operator=(const TMLCompData& aOther)
+	{
+	if (this != &aOther)
+		{
+		iName = aOther.iName;
+		iCanBeMirror = aOther.iCanBeMirror;
+		for (const_iterator pTab = aOther.begin(); pTab != aOther.end(); ++pTab)
+			push_back(new TMLCompDataTable(this, **pTab));
+		Compile();
+		}
+	return *this;
+	}
+
+TMLCompData::~TMLCompData()
+	{
+	for (iterator pTab = begin(); pTab != end(); ++pTab)
+		delete *pTab;
+	DeleteComponents();
+	delete iAttributes;
+	}
+
+TMLCompDataLine* TMLCompData::FindComponent(const string& aName) const
+	{
+	for (TMLComponents::const_iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLCompDataLine* line = pComp->second;
+		if (line->Name() == aName)
+			return line;
+		}
+
+	return 0;
+	}
+
+TMLCompDataLine* TMLCompData::FindLine(const string& aName) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		TMLCompDataLine* line = (*pTab)->FindLine(aName);
+		if (line)
+			return line;
+		}
+
+	return 0;
+	}
+
+TMLCompDataTable* TMLCompData::FindTable(const string& aName) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		if ((*pTab)->Name() == aName)
+			return *pTab;
+		}
+
+	return 0;
+	}
+
+TMLCompDataTable* TMLCompData::FindTable(int aId) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		if ((*pTab)->iId == aId)
+			return *pTab;
+		}
+
+	return 0;
+	}
+
+TMLCompDataTable::TMLCompDataSubTable* TMLCompData::FindSubTable(const string& aName) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		TMLCompDataTable::TMLCompDataSubTable* sub = (*pTab)->FindSubTable(aName);
+		if (sub)
+			return sub;
+		}
+
+	return 0;
+	}
+
+
+void TMLCompData::Merge(TMLCompData& aOther)
+	{
+	iName = aOther.iName;
+	iCanBeMirror |= aOther.iCanBeMirror; // in the case of an elaf layout merging onto an abrw layout, the chirality will be preserved
+	MergeComponents(aOther);
+	}
+
+void TMLCompData::MergeComponents(TMLCompData& aOther)
+    {
+	for (TMLComponents::iterator pOtherLine = aOther.iComponents.begin(); pOtherLine != aOther.iComponents.end(); ++pOtherLine)
+		{
+		TMLCompDataLine& otherLine = *(pOtherLine->second);
+        TMLCompDataLine* found = FindComponent(otherLine.iName);
+        if(found)
+			{
+			found->Merge(otherLine);
+			}
+		else
+			{
+			TMLCompDataLine* newLine = new TMLCompDataLine(otherLine);
+			iComponents.insert(make_pair(otherLine.iId, newLine));
+			}
+		}
+	}
+
+void TMLCompData::Compile()
+	{
+	CreateTables();
+
+	// now add a special table for the screen contents
+	TMLCompDataTable* topTab = new TMLCompDataTable(this);
+	topTab->iId = -1;
+	topTab->iName = KCompDataKeywordScreenContents;
+
+	// then insert each line into its parent
+	for (TMLComponents::iterator pComp2 = iComponents.begin(); pComp2 != iComponents.end(); ++pComp2)
+		{
+		TMLCompDataLine& line = *(pComp2->second);
+		if(line.iType == TMLCompDataLine::EScreenComponent)
+			{
+			line.iParentTable = topTab;
+			topTab->push_back(&line);
+			}
+		else
+			{
+			bool parentFound = false;
+			int parentId = 0;
+			if(line.iParentInfo)
+				{
+				TMLCompDataParentInfo& parentInfo = *(line.iParentInfo);
+				TMLCompDataParentInfoSelector& selector = (parentInfo.begin())->second; // we ignore the varieties for now
+				parentId = selector.iParentId;
+				TMLCompDataTable* parentTable = FindTable(parentId);
+				TMLCompDataLine* parentLine = iComponents[parentId];
+				if(parentTable)
+					{
+					line.iParentTable = parentTable;
+					// copy the pointer from the components table
+					parentTable->push_back(&line);
+					parentFound = true;
+					// now insert the table into its place in the tree
+					parentTable->iParentLine = iComponents[parentId];
+					}
+				else
+					{
+					parentFound = false;
+					}
+				}
+			if(!parentFound)
+				{
+                string errorText = string(" TMLCompData::Compile() - can't find parent component: ");
+				errorText += CdlTkUtil::IntToString(parentId);
+				throw GeneralErr(errorText);
+				}
+			}		
+		}	
+	push_back(topTab);
+	
+	// remember not to delete the components, as we have taken copies!
+	iComponents.clear();
+
+	// now compile the tables
+	iterator pTab;
+	for (pTab = begin(); pTab != end(); ++pTab)
+		(*pTab)->Compile();
+
+	// now sort the tables
+	sort(begin(), end(), TMLCompDataTable::lessthan);	
+	}
+
+void TMLCompData::CreateTables()
+	{
+	// from the list of components, first create a table for each pane
+	for (TMLComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLCompDataLine& line = *(pComp->second);
+		switch(line.iType)
+			{
+			case TMLCompDataLine::EScreenComponent:
+			case TMLCompDataLine::EContainerComponent:
+			case TMLCompDataLine::EPaneComponent:
+				{
+				TMLCompDataTable* tab = new TMLCompDataTable(this);
+				tab->iId = line.iId;
+				tab->iName = line.iName;
+				push_back(tab);
+				break;
+				}
+			case TMLCompDataLine::EGraphicComponent:
+			case TMLCompDataLine::ETextComponent:
+				{
+				// text and graphic components are not panes 
+				// and are therefore not represented in our internal object model as tables
+				break;
+				}
+			default:
+				{
+				cout << "TMLCompData::CreateTables() - uncategorised component\n";
+				break;
+				}
+			}	
+		}
+	}
+
+void TMLCompData::DeleteComponents()
+	{
+	for (TMLComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		delete pComp->second;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompData2Cdl.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,546 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "MLCompData2Cdl.h"
+#include "MLCompDataParse.h"
+#include "MLAttributesParse.h"
+#include "LayoutCompilerErr.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+#include "CppWriter.h"
+#include "CodeGenConsts.h"
+
+using namespace std;
+
+typedef LayoutProcessArgsErr<MLCompDataToCdl> MLCompDataToCdlArgsErr;
+
+// constants
+
+const int KGeneratedInterfaceMajorVer = 1;
+const int KGeneratedInterfaceMinorVer = 0;
+
+const string KCompDataFileNameSuffix("compData");
+const string KAttributesFileNameSuffix("attributes");
+
+
+// 
+// MLCompDataToCdl
+//
+MLCompDataToCdl::CApiNamesUsed MLCompDataToCdl::iInterfaceNamesUsed;
+
+string MLCompDataToCdl::InterfaceName(const string& aFileName)
+	{
+	return aFileName.substr(0,aFileName.find_last_of('.'));
+	}
+
+int MLCompDataToCdl::Process(const vector<string>& args)
+	{
+	iInterfaceNamesUsed.clear();
+
+	int numExpectedArgs = 4;
+	if(args.size() < numExpectedArgs)
+		throw MLCompDataToCdlArgsErr();
+
+    int arg = 2;
+	bool deletesAllowed = true;
+	if (args[arg] == "-nodeletes")
+		{
+		deletesAllowed = false;
+		arg++;
+		numExpectedArgs++;
+		}
+
+	bool allParams = false;
+	if (args[arg] == "-allparams")
+		{
+		allParams = true;
+		arg++;
+		numExpectedArgs++;
+		}
+
+	bool romOnly = false;
+	if (args[arg] == "-romonly")
+		{
+		romOnly = true;
+		arg++;
+		numExpectedArgs++;
+		}
+
+	int numLayouts = args.size() - numExpectedArgs;
+	if (numLayouts < 1)
+		throw MLCompDataToCdlArgsErr();
+
+	TMLCompData* mergedLayout = NULL;
+	TMLAttributes* mergedAttribs = NULL;
+    for(int ii = 0; ii < numLayouts; ii++)
+        {
+		string layoutName = args[arg++];
+		string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName);
+
+		auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName);
+		auto_ptr<TMLCompData> layout(layoutParse.get());
+		layoutParse.release();
+
+		auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName);
+		auto_ptr<TMLAttributes> attribs(attribsParse.get());
+		attribsParse.release();
+
+		if (mergedLayout || mergedAttribs)
+			{
+			// first we merge the components and the attributes
+			mergedLayout->MergeComponents(*layout);
+			mergedAttribs->Merge(*attribs);
+			}
+		else
+			{
+			// first time around
+			mergedLayout = layout.get();
+			mergedAttribs = attribs.get();
+			}
+        layout.release();
+		attribs.release();
+        }
+
+	mergedLayout->iAttributes = mergedAttribs; // transfer ownership
+
+	// once merged, we can compile the tables
+    mergedLayout->Compile();
+
+	string cdlName = args[arg++];
+	int uid = CdlTkUtil::ParseInt(args[arg++]);
+
+	auto_ptr<CCdlTkInterface> iface(new CCdlTkInterface);
+	CCdlTkCdlFileParser parser(cdlName);
+	try
+		{
+		iface = parser.LoadAndParse(true);
+		}
+	catch (const CdlTkFileOpenErr& aErr)
+		{
+		// there was no file, so presume that we are creating a new interface.
+		aErr.Show(cerr);
+		cout << "Creating new CDL API from scratch." << endl;
+		}
+
+	LayoutToInterface(*iface, *mergedLayout, deletesAllowed, allParams);
+
+	stringstream comment;
+	comment << "// Generated from ";
+
+	// ignore the args up to and including the app name, the mode name, and the optional flags, 
+    arg = numExpectedArgs-2; 
+
+	// so that we get a list of processed files to output to the comment
+    for(ii = 0; ii < numLayouts; ii++)
+		comment << args[arg++] << ", ";
+    comment << endl; 
+	comment << "// which was generated with timestamp " << mergedLayout->iTimestamp << endl;
+
+	SetHeaders(*iface, cdlName, comment.str(), uid, romOnly);
+
+	CCdlTkWriteCdlFile writer(*iface);
+	cout << "writing CDL file " << cdlName << endl;
+	writer.Process();
+
+	iInterfaceNamesUsed.clear();
+	return 0;
+	}
+
+void MLCompDataToCdl::ShowHelp(ostream& stream)
+	{
+	stream << "MLCompData2Cdl [-nodeletes] [-allparams] [-romonly] (<MLCompDataName>)+ <cdlName> <UID>" << endl;
+	stream << "  If the CDL file does not exist, writes out the API in the order of the MLCompData." << endl;
+	stream << "  If the CDL file does exist, and -nodeletes is not used, fills holes and appends new APIs to the end, to preseve API compatibility." << endl;
+	stream << "  If the CDL file does exist, and -nodeletes is used, processing will halt and report an error if any of the existing APIs are missing." << endl;
+	stream << "  If the CDL file does exist, existing APIs that do not have required params will be updated, appending missing params with default values." << endl;
+	stream << "  If -allparams is used, all processed APIs will have all available params added, otherwise only needed params are added." << endl;
+	stream << "  If -romonly is used, and if there is a previous CDL API it did not include the KCdlFlagRomOnly flag, then the flag will be added to the updated API." << endl;
+	stream << "  If more than one layout is supplied, they are merged together, and then the interface of the merged data is generated. " << endl;
+    stream << "  e.g. from \\S60\\AknLayout2\\group run " << endl;
+    stream << "  aknlayoutcompiler MLCompData2CDL -nodeletes ..\\xml\\pdp_av_dbl_prt\\display_eur_compData.xml ..\\xml\\pdl_av_dbl_lsc\\display_eur_compData.xml ..\\cdl\\AknLayoutScalable_Avkon.cdl 0x1020384E" << endl;
+    stream << "  aknlayoutcompiler MLCompData2CDL -nodeletes ..\\xml\\pdp_apps_dbl_prt\\display_eur_compData.xml ..\\xml\\pdl_apps_dbl_lsc\\display_eur_compData.xml ..\\cdl\\AknLayoutScalable_Apps.cdl 0x1020384F" << endl;
+	}
+
+void MLCompDataToCdl::LayoutToInterface(CCdlTkInterface& aInterface, const TMLCompData& aLayout, bool aDeletesAllowed, bool aAllParams)
+	{
+	const bool needsOptions = true;
+	const bool needsColsRows = true;
+	const bool doesntNeedOptions = false;
+	const bool doesntNeedColsRows = false;
+
+	AddGenericApiToInterface(aInterface, KTypeLayoutScalableComponentType, KFuncGetComponentTypeById, doesntNeedOptions, doesntNeedColsRows);
+	AddGenericApiToInterface(aInterface, KTypeLayoutScalableParameterLimits, KFuncGetParamLimitsById, needsOptions, doesntNeedColsRows);
+	AddGenericApiToInterface(aInterface, KTypeWindowComponentLayout, KFuncGetWindowComponentById, needsOptions, needsColsRows);
+	AddGenericApiToInterface(aInterface, KTypeTextComponentLayout, KFuncGetTextComponentById, needsOptions, needsColsRows);
+
+	for (TMLCompData::const_iterator pTab = aLayout.begin(); pTab != aLayout.end(); ++pTab)
+		{
+		AddTableToInterface(aInterface, **pTab, aAllParams);
+		}
+	ReplaceRemovedAPIs(aInterface, aLayout, aDeletesAllowed);
+	CleanUpAPIComments(aInterface);
+	}
+
+void MLCompDataToCdl::AddGenericApiToInterface(CCdlTkInterface& aInterface, const string& aReturnType, const string& aName, bool aNeedsOptions, bool aRequiresColsRows)
+	{
+	bool isNew = false;
+	const bool needsComponentId = true;
+	const bool doesntNeedAllParams = false;
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, aReturnType, aName, isNew);
+
+	CCdlTkApiParams& params = funcApi->Params();
+	CCdlTkApiParams oldParams = params;
+	UpdateParams(oldParams, params, aName, doesntNeedAllParams, aRequiresColsRows, isNew, needsComponentId, aNeedsOptions, aRequiresColsRows, aRequiresColsRows);
+
+	funcApi->SetComment(string("// Generic API\n"));
+	}
+
+void MLCompDataToCdl::AddTableToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, bool aAllParams)
+	{
+	int line = 0;
+	for (TMLCompDataTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		// only add parameter limits if the line is not simple
+		bool needsParamLimits = (*pLine)->NeedsOptions() || (*pLine)->NeedsCols() || (*pLine)->NeedsRows();
+		if(needsParamLimits)
+			{
+			AddParamLimitsToInterface(aInterface, **pLine, aAllParams);
+			}
+		AddLineToInterface(aInterface, **pLine, aAllParams);
+
+		for (TMLCompDataTable::TMLCompDataSubTables::const_iterator pSub = aTable.iSubTables.begin(); pSub != aTable.iSubTables.end(); ++pSub)
+			{
+			TMLCompDataTable::TMLCompDataSubTable& sub = **pSub;
+			int last = *(sub.rbegin());
+			if(line == last)
+				{
+				AddSubTableLimitsToInterface(aInterface, aTable, sub);
+				if(needsParamLimits)
+					AddSubTableParamLimitsToInterface(aInterface, aTable, sub, aAllParams);
+				AddSubTableToInterface(aInterface, aTable, sub, aAllParams);
+				}
+			}
+
+		line++;
+		}
+	}
+
+void MLCompDataToCdl::AddTableCommentToApi(TMLCompDataTable& aTable, CCdlTkApi& aApi)
+	{
+	aApi.SetComment(string("// LAF Table : ") + aTable.Name() + "\n");
+	}
+
+void MLCompDataToCdl::AddTableCommentToApi(TMLCompDataLine& aLine, CCdlTkApi& aApi)
+	{
+	if(aLine.iParentTable)
+		{
+		TMLCompDataTable& table = *(aLine.iParentTable);
+		AddTableCommentToApi(table, aApi);
+		}
+	}
+
+void MLCompDataToCdl::AddLineToInterface(CCdlTkInterface& aInterface, TMLCompDataLine& aLine, bool aAllParams)
+	{
+	bool isNew = false;
+	const bool requiresColsRows = true;
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, ReturnType(aLine), LineApiName(aLine), isNew);
+	AddParamsToFunc(aLine, *funcApi, aAllParams, isNew, requiresColsRows);
+	AddTableCommentToApi(aLine, *funcApi);
+	}
+
+void MLCompDataToCdl::AddParamLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataLine& aLine, bool aAllParams)
+	{
+	bool isNew = false;
+	const bool doesntRequireColsRows = false;
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, KTypeLayoutScalableParameterLimits, LineParamLimitsApiName(aLine), isNew);
+	AddParamsToFunc(aLine, *funcApi, aAllParams, isNew, doesntRequireColsRows);
+	AddTableCommentToApi(aLine, *funcApi);
+	}
+
+void MLCompDataToCdl::AddSubTableToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, bool aAllParams)
+	{
+	bool isNew = false;
+	const bool requiresColsRows = true;
+	TMLCompDataLine& line = *aTable[aSubTable[0]];
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, ReturnType(line), SubTableApiName(aSubTable), isNew);
+	AddParamsToFunc(aTable, aSubTable, *funcApi, aAllParams, isNew, requiresColsRows);
+	AddTableCommentToApi(aTable, *funcApi);
+	}
+
+void MLCompDataToCdl::AddSubTableLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable)
+	{
+	bool isNew = false;
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, KTypeLayoutScalableTableLimits, SubTableLimitsApiName(aSubTable), isNew);
+	AddTableCommentToApi(aTable, *funcApi);
+	}
+
+void MLCompDataToCdl::AddSubTableParamLimitsToInterface(CCdlTkInterface& aInterface, TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, bool aAllParams)
+	{
+	bool isNew = false;
+	const bool doesntRequireColsRows = false;
+	CCdlTkFunctionApi* funcApi = ProcessFunctionApi(aInterface, KTypeLayoutScalableParameterLimits, SubTableParamLimtsApiName(aSubTable), isNew);
+	AddParamsToFunc(aTable, aSubTable, *funcApi, aAllParams, isNew, doesntRequireColsRows);
+	AddTableCommentToApi(aTable, *funcApi);
+	}
+
+void MLCompDataToCdl::AddParamsToFunc(TMLCompDataLine& aLine, CCdlTkFunctionApi& aFunc, bool aAllParams, bool aIsNew, bool aColsRowsRequired)
+	{
+	CCdlTkApiParams& params = aFunc.Params();
+	CCdlTkApiParams oldParams = params;
+
+	const bool doesntNeedComponentId = false;
+	bool options = aLine.NeedsOptions();
+	bool cols = aLine.NeedsCols();
+	bool rows = aLine.NeedsRows();
+	UpdateParams(oldParams, params, LineApiName(aLine), aAllParams, aColsRowsRequired, aIsNew, doesntNeedComponentId, options, cols, rows);
+	}
+
+void MLCompDataToCdl::AddParamsToFunc(TMLCompDataTable& aTable, TMLCompDataTable::TMLCompDataSubTable& aSubTable, CCdlTkFunctionApi& aFunc, bool aAllParams, bool aIsNew, bool aColsRowsRequired)
+	{
+	CCdlTkApiParams& params = aFunc.Params();
+	CCdlTkApiParams oldParams = params;
+
+	if(aIsNew || params.FindByName(KParamLineIndex) == params.end())
+		params.insert(params.begin(), CCdlTkApiParam(KTypeInt, KParamLineIndex));
+
+	const bool doesntNeedComponentId = false;
+	bool options = aSubTable.iNeedsOption;
+	bool cols = aSubTable.iNeedsCol;
+	bool rows = aSubTable.iNeedsRow;
+	UpdateParams(oldParams, params, SubTableApiName(aSubTable), aAllParams, aColsRowsRequired, aIsNew, doesntNeedComponentId, options, cols, rows);
+	}
+
+void MLCompDataToCdl::SetHeaders(CCdlTkInterface& aInterface, const string& aCdlName, const string& aComment, int aUid, bool aRomOnly)
+	{
+	aInterface.SetFileName(aCdlName);
+	aInterface.SetAdditionalComment(aComment);
+	aInterface.Header().SetUid(aUid);
+
+    // Note that if the rom only flag was already set in the existing API, then it will remain on
+    // even if -romonly was not supplied as a command line argument. To remove the flag, 
+    // the CDL file must be manually edited.
+    if(aRomOnly)
+    	aInterface.Header().Flags().SetFlag("KCdlFlagRomOnly");
+
+	string ifName(InterfaceName(CdlTkUtil::StripPath(aCdlName)));
+	aInterface.Header().SetName(ifName);
+	aInterface.Header().SetVersion(CCdlTkInterfaceHeader::CVersion(KGeneratedInterfaceMajorVer, KGeneratedInterfaceMinorVer));
+
+	CCdlTkCpp& cpp = aInterface.Cpp();
+	int size = cpp.size();
+	if(!find(cpp.begin(), cpp.end(), KIncludeLayoutInstanceHeaderScalableDef))
+		cpp.push_back(KIncludeLayoutInstanceHeaderScalableDef);
+	}
+
+string MLCompDataToCdl::SubTableApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable)
+	{
+	return CdlTkUtil::ToCpp(aSubTable.iName);
+	}
+
+string MLCompDataToCdl::SubTableLimitsApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable)
+	{
+	return CdlTkUtil::ToCpp(aSubTable.iName + KFuncLimitsSuffix);
+	}
+
+string MLCompDataToCdl::SubTableParamLimtsApiName(TMLCompDataTable::TMLCompDataSubTable& aSubTable)
+	{
+	return CdlTkUtil::ToCpp(aSubTable.iName + KFuncParamLimitsSuffix);
+	}
+
+string MLCompDataToCdl::LineApiName(TMLCompDataLine& aLine)
+	{
+	return CdlTkUtil::ToCpp(aLine.iName);
+	}
+
+string MLCompDataToCdl::LineParamLimitsApiName(TMLCompDataLine& aLine)
+	{
+	return CdlTkUtil::ToCpp(aLine.iName + KFuncParamLimitsSuffix);
+	}
+
+string MLCompDataToCdl::ReturnType(TMLCompDataLine& aLine)
+	{
+	string returnType = "BadType";
+	switch(aLine.iType)
+		{
+		case TMLCompDataLine::EScreenComponent:
+		case TMLCompDataLine::EContainerComponent:
+		case TMLCompDataLine::EPaneComponent:
+		case TMLCompDataLine::EGraphicComponent:
+			{
+			returnType = KTypeWindowComponentLayout;
+			break;
+			}
+		case TMLCompDataLine::ETextComponent:
+			{
+			returnType = KTypeTextComponentLayout;
+			break;
+			}
+		default:
+			{
+			throw GeneralErr(" MLCompDataToCdl::ReturnType - uncategorised component");
+			break;
+			}
+		}
+
+	return returnType;
+	}
+
+void MLCompDataToCdl::ReplaceRemovedAPIs(CCdlTkInterface& aInterface, const TMLCompData& aLayout, bool aDeletesAllowed)
+	{
+	bool error = false;
+	// look for apis for which there is no equivalent internal structure. 
+	CCdlTkApiList& apiList = aInterface.ApiList();
+	for(CCdlTkApiList::reverse_iterator pApi = apiList.rbegin(); pApi != apiList.rend(); ++pApi)
+		{
+		CCdlTkApi*& api = *pApi;
+		string apiName = api->Name();
+		if(iInterfaceNamesUsed.find(apiName) == iInterfaceNamesUsed.end())
+			{
+			if(aDeletesAllowed)
+				{
+				delete api; // remove the missing api
+				CCdlTkApi*& last = *(apiList.rbegin()); // get a reference to the pointer to the last element
+				api = last; // copy the last element pointer to fill the gap
+
+				// erasing the last element will not invalidate our reverse iterator
+				// but we need a forward iterator to the last element, 
+				// so take the address of our reference to the pointer
+				apiList.erase(&last); 
+				cout << "Replacing missing API: " << apiName << " <- " << api->Name() << endl;
+				}
+			else
+				{
+				error = true;
+				cout << "Detected missing API: " << apiName << endl;
+				}
+			}
+		}
+	if(error)
+		{
+		throw GeneralErr("Error: -nodeletes was specified on command line, but some APIs were missing.");
+		}
+	}
+
+void MLCompDataToCdl::CleanUpAPIComments(CCdlTkInterface& aInterface)
+	{
+	string currentComment;
+	CCdlTkApiList& apiList = aInterface.ApiList();
+	for(CCdlTkApiList::iterator pApi = apiList.begin(); pApi != apiList.end(); ++pApi)
+		{
+		CCdlTkApi& api = **pApi;
+		string nextComment = api.Comment();
+		if(nextComment == currentComment)
+			api.SetComment(string());
+		else
+			currentComment = nextComment;
+		}
+	}
+
+CCdlTkFunctionApi* MLCompDataToCdl::ProcessFunctionApi(CCdlTkInterface& aInterface, string aReturnType, string aName, bool& aIsNew)
+	{
+	iInterfaceNamesUsed.insert(aName);
+	CCdlTkFunctionApi* funcApi;
+	CCdlTkApi* api = aInterface.ApiList().Find(aName);
+	if(api)
+		{
+		funcApi = static_cast<CCdlTkFunctionApi*>(api);
+		UpdateFunctionApi(*funcApi, aInterface, aReturnType, aName);
+		}
+	else
+		{
+		funcApi = CreateFunctionApi(aInterface, aReturnType, aName);
+		aIsNew = true;
+		}
+	funcApi->SetReturnType(aReturnType);
+	funcApi->SetName(aName);
+	return funcApi;
+	}
+
+CCdlTkFunctionApi* MLCompDataToCdl::CreateFunctionApi(CCdlTkInterface& aInterface, string aReturnType, string aName)
+	{
+	cout << "Adding new API: " << aName << endl;
+	CCdlTkFunctionApi* api = new CCdlTkFunctionApi(aInterface);
+	api->SetReturnType(aReturnType);
+	api->SetName(aName);
+	aInterface.ApiList().push_back(api);
+	return api;	
+	}
+
+void MLCompDataToCdl::UpdateFunctionApi(CCdlTkFunctionApi& aApi, CCdlTkInterface& aInterface, string aReturnType, string aName)
+	{
+	aApi.SetReturnType(aReturnType);
+	aApi.SetName(aName);
+	}
+
+void MLCompDataToCdl::UpdateParams(
+	CCdlTkApiParams& aOldParams, 
+	CCdlTkApiParams& aParams, 
+	string aApiName, 
+	bool aAllParamsRequested,
+	bool aColsRowsRequired,
+	bool aIsNew, 
+	bool aNeedsComponentId,
+	bool aNeedsOptions, 
+	bool aNeedsCols, 
+	bool aNeedsRows)
+	{
+	const bool allParamsDoesntApply = false;
+	AddParamToParams(aOldParams, aParams, KParamComponentId, allParamsDoesntApply, aIsNew, aNeedsComponentId);
+	AddParamToParams(aOldParams, aParams, KParamOptionIndex, aAllParamsRequested, aIsNew, aNeedsOptions);
+	AddParamToParams(aOldParams, aParams, KParamColIndex, aAllParamsRequested && aColsRowsRequired, aIsNew, aNeedsCols && aColsRowsRequired);
+	AddParamToParams(aOldParams, aParams, KParamRowIndex, aAllParamsRequested && aColsRowsRequired, aIsNew, aNeedsRows && aColsRowsRequired);
+
+	if(aOldParams != aParams)
+		cout << "Updating parameters: " << aApiName << endl;
+	}
+
+void MLCompDataToCdl::AddParamToParams(
+	CCdlTkApiParams& aOldParams, 
+	CCdlTkApiParams& aParams, 
+	string aType, 
+	bool aAllParamsRequested, 
+	bool aIsNewLine, 
+	bool aNeedsParam)
+	{
+	// only add new params if needed
+	bool alreadyPresent = aOldParams.FindByName(aType) != aOldParams.end();
+	if((aNeedsParam || aAllParamsRequested) && !alreadyPresent)
+		{
+		// the only circumstance in which we don't use a default parameter, 
+		// is if we're adding a needed param to a new line
+		bool needsDefaultValue = !(aIsNewLine && aNeedsParam);
+		
+		string defaultValue;
+		if(aParams.size() != 0 && aParams.back().DefaultValue() == CdlTkUtil::IntToString(0))
+		{
+			defaultValue = CdlTkUtil::IntToString(0);
+		}
+		else
+		{
+			defaultValue = needsDefaultValue ? CdlTkUtil::IntToString(0) : string();
+		}
+		CCdlTkApiParam param(KTypeInt, aType, defaultValue);
+		aParams.push_back(param);
+	}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompData2LayPerf.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,126 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated"
+#pragma warning (disable:4503)
+
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+
+#include "LayoutCompilerErr.h"
+#include "MLCompDataParse.h"
+#include "MLAttributesParse.h"
+#include "MLCompData2LayPerf.h"
+#include "MLCompDataLayPerfWriter.h"
+
+typedef LayoutProcessArgsErr<MLCompDataToLayPerf> MLCompDataToLayPerfArgsErr;
+
+const string KCompDataFileNameSuffix("compData");
+const string KAttributesFileNameSuffix("attributes");
+
+//------------------------------------
+// class MLCompDataToLayPerf
+//------------------------------------
+int MLCompDataToLayPerf::Process(const vector<string>& args)
+	{
+	if (args.size() != 6)
+		throw MLCompDataToLayPerfArgsErr();
+
+    int arg = 2;
+	string cdlName = args[arg++];
+
+	CCdlTkCdlFileParser parser(cdlName);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+
+	int numLayouts = args.size() - 4;
+	if (numLayouts < 1)
+		throw MLCompDataToLayPerfArgsErr();
+
+	TMLCompData* mergedLayout = NULL;
+	TMLAttributes* mergedAttribs = NULL;
+    for(int ii = 0; ii < numLayouts; ii++)
+        {
+		string layoutName = args[arg++];
+		string attribsName = CdlTkUtil::Replace(KCompDataFileNameSuffix, KAttributesFileNameSuffix, layoutName);
+
+		auto_ptr<TMLCompDataParseLayout> layoutParse = TMLCompDataParseLayout::Parse(layoutName);
+		auto_ptr<TMLCompData> layout(layoutParse.get());
+		layoutParse.release();
+
+		auto_ptr<TMLAttributesParse> attribsParse = TMLAttributesParse::Parse(attribsName);
+		auto_ptr<TMLAttributes> attribs(attribsParse.get());
+		attribsParse.release();
+
+		if (mergedLayout || mergedAttribs)
+			{
+			// first we merge the components and the attributes
+			mergedLayout->MergeComponents(*layout);
+			mergedAttribs->Merge(*attribs);
+			}
+		else
+			{
+			// first time around
+			mergedLayout = layout.get();
+			mergedAttribs = attribs.get();
+			}
+        layout.release();
+		attribs.release();
+        }
+
+	mergedLayout->iAttributes = mergedAttribs; // transfer ownership
+
+	// once merged, we can compile the tables
+    mergedLayout->Compile();
+
+
+	string destLayout = args[arg++];
+	MLCompDataToLayPerf layPerf(cdlName, *iface, *mergedLayout, destLayout);
+	layPerf.WriteLayout();
+
+	return 0;
+	}
+
+void MLCompDataToLayPerf::ShowHelp(ostream& stream)
+	{
+	stream << "MLCompData2LayPerf <layout.cdl> (<MLCompDataName>)+ <layPerf.cpp> " << endl;
+	stream << "MLCompData2LayPerf ..\\cdl\\AknLayoutScalable_Avkon.cdl ..\\xml\\pdp_av_dbl_prt\\display_eur_compData.xml ..\\xml\\pdl_av_dbl_lsc\\display_eur_compData.xml ..\\generated\\LayPerf_AknLayoutScalable_Avkon.cpp " << endl;
+	stream << "  This converts a CDL file into a specialised format for inclusion in the LayPerfScalable2 test app." << endl;
+	stream << "  LayPerfScalable2 runs on the device, calling each API that would be generated from the CDL file." << endl;
+	}
+
+MLCompDataToLayPerf::MLCompDataToLayPerf(const string& aCdlName, CCdlTkInterface& aInterface, TMLCompData& aSourceLayout, const string& aDestLayoutName)
+    :	
+	iCdlName(aCdlName),
+	iInterface(aInterface), 
+	iLayout(aSourceLayout),
+	iDestLayoutName(aDestLayoutName)
+	{
+	}
+
+void MLCompDataToLayPerf::WriteLayout()
+	{
+	TMLCompDataLayPerfWriter writer(iInterface, iLayout, iDestLayoutName);
+	writer.Write(iCdlName);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompDataLayPerfWriter.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,222 @@
+/*
+* 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 "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: 
+*    
+*
+*/
+
+
+#include "MLCompDataLayPerfWriter.h"
+#include "MLCompData2Cdl.h" // for static methods
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+
+#include <cdlcompilertoolkit/cdltkinterface.h>
+#include <cdlcompilertoolkit/cdltkutil.h>
+
+#include <iostream>
+#include <sstream>
+#include <set>
+#include <fstream>
+#include <algorithm>
+
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+const string KComma = ",";
+const string KSpace = " ";
+const string KMacroNameRoot = "LAYOUT_TEST";
+const string KMacroNameWindow = "_WINDOW";
+const string KMacroNameText = "_TEXT";
+const string KMacroNameComponent = "_COMPONENT";
+const string KMacroNameParams = "_PARAMS";
+
+//
+// TMLCompDataLayPerfTableWriter
+//
+
+TMLCompDataLayPerfTableWriter::TMLCompDataLayPerfTableWriter(TMLCompDataLayPerfWriter* aParent, TMLCompDataTable& aTable, string& aInterfaceName, int aTableId) 
+	: 
+	iParent(aParent),
+	iTable(aTable),
+	iInterfaceName(aInterfaceName),
+	iTableId(aTableId)
+	{
+	}
+
+TMLCompDataLayPerfTableWriter::~TMLCompDataLayPerfTableWriter()
+	{
+	}
+
+void TMLCompDataLayPerfTableWriter::Write(ostream& out)
+	{
+	WriteTable(out);
+	}
+
+
+const string KTestAPITableFuntionSig = "\
+testLayout_$LAYOUT_$TABLEID()";
+
+string GenerateMLFunctionName(string aInterfaceName, int aTableId)
+	{
+	string tableNum = CdlTkUtil::IntToString(aTableId);
+
+	CdlTkUtil::CReplaceSet rep;
+	rep.Add("$LAYOUT", aInterfaceName);
+	rep.Add("$TABLEID", tableNum);
+	return CdlTkUtil::MultiReplace(rep, KTestAPITableFuntionSig);
+	}
+
+void TMLCompDataLayPerfTableWriter::WriteTable(ostream& out)
+	{
+	out << "void " << GenerateMLFunctionName(iInterfaceName, iTableId) << endl;
+
+	out << "{" << endl; // start of function
+	out << "DECLARE_LOCAL_VARS_COUNTS" << endl;
+	
+	out << "\n// Layout MACROs for Layout Table : ";
+	out << iTable.Name() << endl;
+
+	for (int i=0; i<iTable.size(); ++i)
+		{
+		WriteLine(out, *iTable[i]);
+		}
+
+	out << endl;
+	out << "}\n" << endl; // end of function
+	}
+
+void TMLCompDataLayPerfTableWriter::WriteLine(ostream& out, TMLCompDataLine& aLine)
+	{
+	string macroName = BuildMacroName(aLine);
+	string apiName = BuildApiName(aLine);
+	string params = BuildParams(aLine);
+	string paramLimitParams = BuildParamLimitParams(aLine);
+
+	out << macroName << "( "; 
+
+	if(aLine.NeedsParams())		
+		{
+		out << 	apiName << KFuncParamLimitsSuffix << "(" << paramLimitParams << ")";
+		out << ", ";
+		}
+
+	out << 	apiName << "(" << params << ")";
+	out << " )" << endl; // this ends the macro call
+	out << endl;
+	}
+
+string TMLCompDataLayPerfTableWriter::BuildMacroName(TMLCompDataLine& aLine)
+	{
+	string macroName = KMacroNameRoot;
+	macroName += (aLine.iType == TMLCompDataLine::ETextComponent) ? KMacroNameText : KMacroNameWindow;
+	macroName += KMacroNameComponent;
+	if(aLine.NeedsParams())		
+		macroName += KMacroNameParams;
+	return macroName;
+	}
+
+string TMLCompDataLayPerfTableWriter::BuildApiName(TMLCompDataLine& aLine)
+	{
+	string apiName = iInterfaceName;
+	apiName += string("::");
+	apiName += MLCompDataToCdl::LineApiName(aLine);
+	return apiName;
+	}
+
+string TMLCompDataLayPerfTableWriter::BuildParams(TMLCompDataLine& aLine)
+	{
+	string paramsString;
+	string name = aLine.Name();
+
+	// add the params in the order of the CDL interface
+	CCdlTkApi* api = iParent->iInterface.ApiList().Find(name);
+	if(!api)
+		throw NotFoundErr(name + " in interface " + iParent->iInterface.FileName());
+	CCdlTkFunctionApi* funcApi = static_cast<CCdlTkFunctionApi*>(api);
+	CCdlTkApiParams& params = funcApi->Params();
+	bool first = true;
+	for(CCdlTkApiParams::iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		{
+		if(!first)
+			{
+			paramsString.append(KComma); 
+			paramsString.append(KSpace);
+			}
+		paramsString.append(pParam->Name());
+		first = false;
+		}
+	return paramsString;
+	}
+
+string TMLCompDataLayPerfTableWriter::BuildParamLimitParams(TMLCompDataLine& aLine)
+	{
+	string paramsString;
+	string name = aLine.Name();
+
+	CCdlTkApi* api = iParent->iInterface.ApiList().Find(name);
+	if(!api)
+		throw NotFoundErr(name + " in interface " + iParent->iInterface.FileName());
+	CCdlTkFunctionApi* funcApi = static_cast<CCdlTkFunctionApi*>(api);
+	CCdlTkApiParams& params = funcApi->Params();
+
+	CCdlTkApiParams::iterator pParam = params.FindByName(KParamOptionIndex);
+	if(pParam != params.end() && aLine.NeedsOptions())
+		{
+		paramsString.append(pParam->Name());
+		}
+
+	return paramsString;
+	}
+
+
+//
+// TMLCompDataLayPerfWriter
+//
+
+TMLCompDataLayPerfWriter::TMLCompDataLayPerfWriter(CCdlTkInterface& aInterface, TMLCompData& aLayout, const std::string& aName)
+	:
+	iInterface(aInterface), 
+	TMLWriterBase<TMLCompData>(aLayout, aName)
+	{
+	}
+
+void TMLCompDataLayPerfWriter::Write(const std::string& aCdlName)
+	{
+	ofstream out(iName.c_str());
+
+	cout << "writing layout " << iName << endl;
+	string cdlFileName(CdlTkUtil::StripPath(aCdlName));
+	string ifName(iInterface.Header().Name());
+
+	out << "// function implementations: " << endl;
+	int tableId = 0;
+	for (TMLCompData::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		TMLCompDataLayPerfTableWriter writer(this, **pTab, ifName, tableId++);
+		writer.Write(out);
+		}
+
+	out << "void testLayout_" << ifName << "()\n{" << endl;
+	tableId = 0;
+	for(;tableId < iLayout.size(); tableId++)
+		{
+		out << GenerateMLFunctionName(ifName, tableId) << ";" << endl;
+		}
+	out << "}\n" << endl;
+
+	out.close();
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLCompDataParse.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,770 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning(disable: 4786 4250 4503 4541)
+
+
+#include "MLCompDataParse.h"
+
+#include <akndef.hrh>
+
+#include <sstream>
+#include <fstream>
+#include <algorithm>
+#include <iostream> // !!! for debug output only
+
+extern string whiteSpace;
+
+
+// 
+// const data
+//
+
+const string KCompDataParseRoot = "Layout";
+
+const string KCompDataParseRootAttributeMasterName = "MasterName";
+const string KCompDataParseRootAttributeLayoutName = "LayoutName";
+const string KCompDataParseRootAttributeVariantName = "variant_name";
+const string KCompDataParseRootAttributeResolutionHeight = "resolutionHeight";
+const string KCompDataParseRootAttributeResolutionWidth = "resolutionWidth";
+const string KCompDataParseRootAttributeCreatedOn = "createdOn";
+
+const string KCompDataParseNodeComponent = "Component";
+const string KCompDataParseNodeComponentAttributeName = "name";
+const string KCompDataParseNodeComponentAttributeId = "id";
+const string KCompDataParseNodeComponentAttributeType = "type";
+const string KCompDataParseNodeComponentAttributeDrawingOrder = "drawingorder";
+const string KCompDataParseNodeComponentAttributeMirror = "mirror";
+const string KCompDataParseNodeComponentAttributeMaxVariety = "maxVariety";
+
+const string KCompDataParseTextComponentTypeScreen= "Screen";
+const string KCompDataParseTextComponentTypeContainer= "Container";
+const string KCompDataParseTextComponentTypePane= "Pane";
+const string KCompDataParseTextComponentTypeGraphic= "Graphic";
+const string KCompDataParseTextComponentTypeText= "Text";
+
+const string KCompDataParseTextComponentMirrorTrue= "true";
+
+const string KCompDataParseNodeOption = "option";
+const string KCompDataParseNodeParentInfo = "ParentInfo";
+const string KCompDataParseNodeLayoutInfo = "LayoutInfo";
+const string KCompDataParseNodeAttributeInfo = "AttributeInfo";
+const string KCompDataParseNodeAttrSets = "attrsets";
+
+const string KCompDataParseNodeParent = "parent";
+const string KCompDataParseNodeParentOption = "option";
+const string KCompDataParseNodeParentOptionAttributeVariety = "variety";
+const string KCompDataParseNodeParentInfoParentAttributeId = "id";
+const string KCompDataParseNodeParentInfoParentAttributeVariety = "variety";
+
+const string KCompDataParseNodeLayoutInfoParam = "Param";
+const string KCompDataParseNodeLayoutInfoParamAttributeName = "name";
+
+const string KCompDataParseNodeValue = "Value";
+const string KCompDataParseNodeVarietyIndex = "varietyIndex";
+const string KCompDataParseNodeVarietyIndexValue = "value";
+const string KCompDataParseNodeCalc = "calc";
+const string KCompDataParseNodeCalcAttributeValue = "value";
+const string KCompDataParseNodeCalcAttributeColNumber = "colNumber";
+const string KCompDataParseNodeCalcAttributeRowNumber = "rowNumber";
+const string KCompDataParseNodeCalcAttributeShowInTable = "showInTable";
+const string KCompDataParseNodeCalcAttributeShowInTableTrue = "true";
+const string KCompDataParseNodeCalcAttributeShowInTableFalse = "false";
+const string KCompDataParseNodeCalcAttributeZoom = "zoom";
+const string KCompDataParseNodeCalcAttributeZoomNormal = "normal";
+const string KCompDataParseNodeCalcAttributeZoomVerySmall = "-2 zoom";
+const string KCompDataParseNodeCalcAttributeZoomSmall = "-1 zoom";
+const string KCompDataParseNodeCalcAttributeZoomLarge = "+1 zoom";
+const string KCompDataParseNodeCalcAttributeZoomVeryLarge = "+2 zoom";
+
+const string KCompDataParseTextFontPrimary = "qfn_primary";
+const string KCompDataParseTextFontSecondary = "qfn_secondary";
+const string KCompDataParseTextFontTitle = "qfn_title";
+const string KCompDataParseTextFontPrimarySmall = "qfn_primary_small"; // is that the correct text?
+const string KCompDataParseTextFontDigital = "qfn_digital";
+
+const string KCompDataParseTextParamNameColor = "Color";
+const string KCompDataParseTextParamShortNameColor = "C";
+const string KCompDataParseTextParamNameLeft = "Left";
+const string KCompDataParseTextParamShortNameLeft = "l";
+const string KCompDataParseTextParamNameRight = "Right";
+const string KCompDataParseTextParamShortNameRight = "r";
+const string KCompDataParseTextParamNameTop = "Top";
+const string KCompDataParseTextParamShortNameTop = "t";
+const string KCompDataParseTextParamNameBottom = "Bottom";
+const string KCompDataParseTextParamShortNameBottom = "b";
+const string KCompDataParseTextParamNameWidth = "Width";
+const string KCompDataParseTextParamShortNameWidth = "W";
+const string KCompDataParseTextParamNameHeight = "Height";
+const string KCompDataParseTextParamShortNameHeight = "H";
+const string KCompDataParseTextParamNameJustification = "Justification";
+const string KCompDataParseTextParamShortNameJustification = "J";
+const string KCompDataParseTextParamNameType = "Type";
+const string KCompDataParseTextParamShortNameType = "Type";
+
+// these have been changed to lower case, so that matching
+// can be performed independent of case
+const string KCompDataParseTextParamTypeCalcValueNone = "none";
+const string KCompDataParseTextParamTypeCalcValueLeft = "left";
+const string KCompDataParseTextParamTypeCalcValueCenter = "center";
+const string KCompDataParseTextParamTypeCalcValueRight = "right";
+const string KCompDataParseTextParamTypeCalcValueBidi = "bidi";
+
+const string KCompDataParseNodeAttributeInfoOption = "option";
+const string KCompDataParseNodeAttributeInfoOptionAttributeVariety = "variety";
+const string KCompDataParseNodeAttributeInfoAttributeSet = "attributeset";
+const string KCompDataParseNodeAttributeInfoAttributeSetAttributeName = "name";
+
+//
+//  TMLCompDataParseValues
+//
+
+TMLCompDataParseValues::TMLCompDataParseValues(TMLCompDataLine* aLine)
+	: 
+	TMLCompDataValues(aLine), 
+	iSaxZoomLevels(0), 
+	iSaxVariety(-1)
+	{
+
+	}
+
+MSaxLayoutHandler* TMLCompDataParseValues::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//	<Param name="Left">
+//		<Value>
+//	      <varietyIndex value="0"/>
+//			<optionIndex value="0"/>
+//			<calc ... >
+//			...
+//		</Value>
+//		...
+//	</Param>
+
+	if (aElement == KCompDataParseNodeValue)
+		{
+		delete iSaxZoomLevels;
+		iSaxZoomLevels = 0;
+		iSaxZoomLevels = new TMLCompDataZoomLevels;
+		}
+	else if (aElement == KCompDataParseNodeVarietyIndex)
+		{
+		HandleSaxVariety(aElement, aAttribs);
+		}
+	else if (aElement == KCompDataParseNodeCalc)
+		{
+		HandleSaxCalc(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+void TMLCompDataParseValues::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KCompDataParseNodeValue)
+		{
+		insert(make_pair(iSaxVariety, *iSaxZoomLevels));
+		delete iSaxZoomLevels;
+		iSaxZoomLevels = 0;
+		}
+	}
+
+void TMLCompDataParseValues::HandleSaxVariety(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+//      <varietyIndex value="0"/>
+
+	string varietyIndexStr = aAttribs.getValue(KCompDataParseNodeVarietyIndexValue);
+	iSaxVariety = CdlTkUtil::ParseInt(varietyIndexStr); // defaults to zero
+	if(iLine->MaxVariety() < iSaxVariety)
+		{
+		iLine->SetMaxVariety(iSaxVariety);
+		}
+	}
+
+void TMLCompDataParseValues::HandleSaxCalc(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+//		<calc value="0"/>
+// or
+//		<calc value="0" zoom="x_2"/>
+// or
+//		<calc colNumber="1" rowNumber="1" value="0"/>
+// or
+//		<calc colNumber="1" rowNumber="1" value="0" zoom="x_2"/>
+
+    // note that if there is only one calc, but the colNumber and rowNumber attributes are present
+    // then we have to assume that it is a multivalue component, so deduce which kind it is from 
+    // the current value name
+
+	// first the index part
+	int max = 1;
+	int cols = 0;
+	int rows = 0;
+
+	string colStr = aAttribs.getValue(KCompDataParseNodeCalcAttributeColNumber);
+	if(!colStr.empty())
+		{
+		cols = CdlTkUtil::ParseInt(colStr);
+        if(TMLCompDataTable::IsHorizontalColumn(iName))
+            {
+            iLine->SetNeedsCols(true);
+            }
+		}
+
+	string rowStr = aAttribs.getValue(KCompDataParseNodeCalcAttributeRowNumber);
+	if(!rowStr.empty())
+		{
+		rows = CdlTkUtil::ParseInt(rowStr);
+        if(TMLCompDataTable::IsVerticalColumn(iName))
+            {
+            iLine->SetNeedsRows(true);
+            }
+		}
+
+	// keep the line updated if we have found more rows / cols than it knows about
+	if(iLine->NumCols() < cols) 
+		iLine->SetNumCols(cols);
+	if(iLine->NumRows() < rows) 
+		iLine->SetNumRows(rows);
+
+	// each calc is either a row or a col (depending on which axis)
+	if(cols > 1)
+		max = cols;
+	else if(rows > 1)
+		max = rows;
+
+	// then the value part of the calc
+	string valueStr;
+	valueStr = aAttribs.getValue(KCompDataParseNodeCalcAttributeValue);
+	ConvertValueStr(valueStr);
+
+	// check whether the calc is a default value (which corresponds to normal zoom)
+	// or if it corresponds to a known zoom factor
+	string zoomStr = aAttribs.getValue(KCompDataParseNodeCalcAttributeZoom);
+	int zoom = ConvertZoomStr(zoomStr);
+	if(zoom != EAknUiZoomAutomatic)
+		{
+		// then put them together
+		int num = max - 1; // change to zero based
+		TMLCompDataCalcs& calcs = (*iSaxZoomLevels)[zoom];
+		calcs[num] = valueStr;
+		}
+	}
+
+void TMLCompDataParseValues::ConvertValueStr(std::string& aValueStr)
+	{
+	int valueInt = 0;
+	if(iName == KCompDataParseTextParamShortNameType)
+		{
+		if(aValueStr == KCompDataParseTextFontPrimary) 
+			valueInt = ELayoutCompilerFontCategoryPrimary;
+		else if(aValueStr == KCompDataParseTextFontSecondary)
+			valueInt = ELayoutCompilerFontCategorySecondary;
+		else if(aValueStr == KCompDataParseTextFontTitle)
+			valueInt = ELayoutCompilerFontCategoryTitle;
+		else if(aValueStr == KCompDataParseTextFontPrimarySmall) 
+			valueInt = ELayoutCompilerFontCategoryPrimarySmall;
+		else if(aValueStr == KCompDataParseTextFontDigital)
+			valueInt = ELayoutCompilerFontCategoryDigital;
+		else
+			valueInt = ELayoutCompilerFontCategoryUndefined;
+		aValueStr = CdlTkUtil::IntToString(valueInt);
+		}
+	else if(iName == KCompDataParseTextParamShortNameJustification)
+		{
+		// jusitication does not have consistent capitalization
+		string lowerValueStr = CdlTkUtil::ToLower(aValueStr);
+		if(lowerValueStr == KCompDataParseTextParamTypeCalcValueNone) 
+			valueInt = ELayoutAlignNone;
+		else if(lowerValueStr == KCompDataParseTextParamTypeCalcValueLeft) 
+			valueInt = ELayoutAlignLeft;
+		else if(lowerValueStr == KCompDataParseTextParamTypeCalcValueRight) 
+			valueInt = ELayoutAlignRight;
+		else if(lowerValueStr == KCompDataParseTextParamTypeCalcValueCenter) 
+			valueInt = ELayoutAlignCenter;
+		else if(lowerValueStr == KCompDataParseTextParamTypeCalcValueBidi) 
+			valueInt = ELayoutAlignBidi;
+		else 
+			valueInt = ELayoutAlignNone;
+		aValueStr = CdlTkUtil::IntToString(valueInt);
+		}
+	}
+
+int TMLCompDataParseValues::ConvertZoomStr(const std::string& aZoomStr)
+	{
+	int zoomInt = EAknUiZoomAutomatic;
+	string lowerZoomStr = CdlTkUtil::ToLower(aZoomStr);
+	if(lowerZoomStr.empty())
+		zoomInt = EAknUiZoomNormal;
+	else if(lowerZoomStr == KCompDataParseNodeCalcAttributeZoomVerySmall) 
+		zoomInt = EAknUiZoomVerySmall;
+	else if(lowerZoomStr == KCompDataParseNodeCalcAttributeZoomSmall) 
+		zoomInt = EAknUiZoomSmall;
+	else if(lowerZoomStr == KCompDataParseNodeCalcAttributeZoomLarge) 
+		zoomInt = EAknUiZoomLarge;
+	else if(lowerZoomStr == KCompDataParseNodeCalcAttributeZoomVeryLarge) 
+		zoomInt = EAknUiZoomVeryLarge;
+	return zoomInt;
+	}
+
+
+//
+//  TMLCompDataParseParentInfo
+//
+
+TMLCompDataParseParentInfo::TMLCompDataParseParentInfo(TMLCompDataLine* aLine)
+	:
+	iSaxParentInfoSelector(0),
+	iSaxVariety(0)
+	{
+	
+	}
+
+MSaxLayoutHandler* TMLCompDataParseParentInfo::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//	<ParentInfo>
+// 		<option variety="0">
+// 			<parent id="3140" variety="2"/>
+//		</option>
+//	</ParentInfo>
+
+	if (aElement == KCompDataParseNodeOption)
+		{
+		delete iSaxParentInfoSelector;
+		iSaxParentInfoSelector= 0;
+		iSaxParentInfoSelector = new TMLCompDataParentInfoSelector;
+		HandleSaxVariety(aElement, aAttribs);
+		}
+	else if (aElement == KCompDataParseNodeParent)
+		{
+		HandleSaxParent(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+void TMLCompDataParseParentInfo::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KCompDataParseNodeOption) // value
+		{
+		insert(make_pair(iSaxVariety, *iSaxParentInfoSelector));
+		delete iSaxParentInfoSelector;
+		iSaxParentInfoSelector = 0;
+		}
+	}
+
+void TMLCompDataParseParentInfo::HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs)
+	{
+// 			<parent id="3140" variety="2"/>
+	string parentIdStr = aAttribs.getValue(KCompDataParseNodeParentInfoParentAttributeId);
+	string parentVarietyStr = aAttribs.getValue(KCompDataParseNodeParentInfoParentAttributeVariety);
+	
+	iSaxParentInfoSelector->iParentId = CdlTkUtil::ParseInt(parentIdStr);
+	iSaxParentInfoSelector->iParentVariety = CdlTkUtil::ParseInt(parentVarietyStr);
+	}
+
+void TMLCompDataParseParentInfo::HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs)
+	{
+// 		<option variety="0">
+	string varietyIndexStr = aAttribs.getValue(KCompDataParseNodeParentOptionAttributeVariety);
+	iSaxVariety = CdlTkUtil::ParseInt(varietyIndexStr); // defaults to zero
+	}
+
+//
+//  TMLCompDataParseLayoutLine
+//
+
+TMLCompDataParseLayoutLine::TMLCompDataParseLayoutLine()
+	: 
+	TMLCompDataLine(), 
+	iSaxValues(0),
+	iSaxParentInfo(0),
+	iSaxAttributeInfo(0)
+	{
+	}
+
+MSaxLayoutHandler* TMLCompDataParseLayoutLine::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if(aElement == KCompDataParseNodeComponent)
+		{
+		HandleSaxAttributes(aAttribs);
+		}
+	else if(aElement == KCompDataParseNodeParentInfo)
+		{
+		return HandleSaxParent(aElement, aAttribs);
+		}
+	else if(aElement == KCompDataParseNodeLayoutInfoParam)
+		{
+		//	<LayoutInfo>
+		//		<Param name="Left">
+		//		...
+		//	</LayoutInfo>
+		return HandleSaxParam(aElement, aAttribs);
+		}
+	else if(aElement == KCompDataParseNodeAttributeInfo)
+		{
+		return HandleSaxAttributeInfo(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+
+void TMLCompDataParseLayoutLine::HandleSaxAttributes(const TAttribs& aAttribs)
+	{
+//	<Component 
+//		drawingorder="0" 
+//		id="1" 
+//		maxVariety="2" 
+//		mirror="true" 
+//		name="application_window" 
+//		type="Container">
+	
+	iName = aAttribs.getValue(KCompDataParseNodeComponentAttributeName);
+
+	string idStr = aAttribs.getValue(KCompDataParseNodeComponentAttributeId);
+	iId = CdlTkUtil::ParseInt(idStr);
+
+	if(iId == 0)
+		{
+		// this must be a dummy component, so have to fabricate a component id
+		// TODO: ensure that layout data contains real component ids
+		if(iName == "text_primary")
+			iId = -1;
+		else if(iName == "text_secondary")
+			iId = -2;
+		else if(iName == "text_title")
+			iId = -3;
+		else if(iName == "text_primary_small")
+			iId = -4;
+		}
+
+	string typeStr = aAttribs.getValue(KCompDataParseNodeComponentAttributeType);
+	if(typeStr == KCompDataParseTextComponentTypeScreen)
+		{
+		iType = EScreenComponent;
+		}
+	else if(typeStr == KCompDataParseTextComponentTypeContainer)
+		{
+		iType = EContainerComponent;
+		}
+	else if(typeStr == KCompDataParseTextComponentTypePane)
+		{
+		iType = EPaneComponent;
+		}
+	else if(typeStr == KCompDataParseTextComponentTypeGraphic)
+		{
+		iType = EGraphicComponent;
+		}
+	else if(typeStr == KCompDataParseTextComponentTypeText)
+		{
+		iType = ETextComponent;
+		}
+	else
+		{
+		iType = EUnknownComponent;
+		}
+
+	string drawingOrderStr = aAttribs.getValue(KCompDataParseNodeComponentAttributeDrawingOrder);
+	iDrawingOrder = CdlTkUtil::ParseInt(drawingOrderStr);
+
+	string mirroredStr = aAttribs.getValue(KCompDataParseNodeComponentAttributeMirror);
+	iIsMirroredHorizontally = (mirroredStr == KCompDataParseTextComponentMirrorTrue); // will be false if empty, eg for a non-mirrored layout
+
+	string maxVarietyStr = aAttribs.getValue(KCompDataParseNodeComponentAttributeMaxVariety);
+	if(!maxVarietyStr.empty()) // screen doesn't have maxVariety for some reason
+		{
+		int maxVariety = CdlTkUtil::ParseInt(maxVarietyStr) - 2;
+		// we ignore the maxVariety for now, as it will be calculated by parsing the values
+		}
+	}
+
+MSaxLayoutHandler* TMLCompDataParseLayoutLine::HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	delete iSaxParentInfo;
+	iSaxParentInfo = 0;
+	iSaxParentInfo = new TMLCompDataParseParentInfo(this);
+	return iSaxParentInfo;
+	}
+
+MSaxLayoutHandler* TMLCompDataParseLayoutLine::HandleSaxParam(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+	delete iSaxValues;
+	iSaxValues = 0;
+	iSaxValues = new TMLCompDataParseValues(this);
+
+	string nameStr = aAttribs.getValue(KCompDataParseNodeLayoutInfoParamAttributeName);
+	iSaxValues->iName = ShortParamName(nameStr);
+
+	return iSaxValues;
+	}
+
+void TMLCompDataParseLayoutLine::HandleSaxEnd(const std::string& aElement)
+	{
+	if(aElement == KCompDataParseNodeParentInfo)
+		{
+		iParentInfo = iSaxParentInfo;
+		iSaxParentInfo = 0;
+		}
+	else if(aElement == KCompDataParseNodeLayoutInfoParam)
+		{
+		insert(make_pair(iSaxValues->iName, *iSaxValues));
+		delete iSaxValues;
+		iSaxValues = 0;
+		}
+	else if(aElement == KCompDataParseNodeAttributeInfo)
+		{
+		iAttributeInfo = iSaxAttributeInfo;
+		iSaxAttributeInfo = 0;
+		}
+	}
+
+MSaxLayoutHandler* TMLCompDataParseLayoutLine::HandleSaxAttributeInfo(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	delete iSaxAttributeInfo;
+	iSaxAttributeInfo = 0;
+	iSaxAttributeInfo = new TMLCompDataParseAttributeInfo(this);
+	return iSaxAttributeInfo;
+	}
+
+string TMLCompDataParseLayoutLine::ShortParamName(string& aName)
+	{
+	string shortName = aName;
+	if(aName == KCompDataParseTextParamNameColor)
+		shortName = KCompDataParseTextParamShortNameColor;
+	else if(aName == KCompDataParseTextParamNameLeft)
+		shortName = KCompDataParseTextParamShortNameLeft;
+	else if(aName == KCompDataParseTextParamNameRight)
+		shortName = KCompDataParseTextParamShortNameRight;
+	else if(aName == KCompDataParseTextParamNameTop)
+		shortName = KCompDataParseTextParamShortNameTop;
+	else if(aName == KCompDataParseTextParamNameBottom)
+		shortName = KCompDataParseTextParamShortNameBottom;
+	else if(aName == KCompDataParseTextParamNameWidth)
+		shortName = KCompDataParseTextParamShortNameWidth;
+	else if(aName == KCompDataParseTextParamNameHeight)
+		shortName = KCompDataParseTextParamShortNameHeight;
+	else if(aName == KCompDataParseTextParamNameJustification)
+		shortName = KCompDataParseTextParamShortNameJustification;
+	else if(aName == KCompDataParseTextParamNameType)
+		shortName = KCompDataParseTextParamShortNameType;
+	return shortName;
+	}
+
+
+//
+//  TMLCompDataParseAttributeInfo
+//
+
+TMLCompDataParseAttributeInfo::TMLCompDataParseAttributeInfo(TMLCompDataLine* aLine)
+	:
+	iSaxAttributeInfoSelector(0),
+	iSaxVariety(0)
+	{
+	
+	}
+
+MSaxLayoutHandler* TMLCompDataParseAttributeInfo::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//        <AttributeInfo>
+//            <option variety="0">
+//                <attributeset name="a0"/>
+//            </option>
+//            <option variety="1">
+//                <attributeset name="a1"/>
+//            </option>
+//        </AttributeInfo>
+
+	if (aElement == KCompDataParseNodeAttributeInfoOption)
+		{
+		delete iSaxAttributeInfoSelector;
+		iSaxAttributeInfoSelector= 0;
+		iSaxAttributeInfoSelector = new TMLCompDataAttributeInfoSelector;
+		HandleSaxVariety(aElement, aAttribs);
+		}
+	else if (aElement == KCompDataParseNodeAttributeInfoAttributeSet)
+		{
+		HandleSaxAttributeSet(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+void TMLCompDataParseAttributeInfo::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KCompDataParseNodeAttributeInfoOption) // value
+		{
+		if(!iSaxAttributeInfoSelector->iAttributeSetName.empty())
+			{
+			insert(make_pair(iSaxVariety, *iSaxAttributeInfoSelector));
+			}
+		delete iSaxAttributeInfoSelector;
+		iSaxAttributeInfoSelector = 0;
+		}
+	}
+
+void TMLCompDataParseAttributeInfo::HandleSaxVariety(const std::string& aElement, const TAttribs& aAttribs)
+	{
+// 		<option variety="0">
+	string varietyIndexStr = aAttribs.getValue(KCompDataParseNodeParentOptionAttributeVariety);
+	iSaxVariety = CdlTkUtil::ParseInt(varietyIndexStr); // defaults to zero
+	}
+
+void TMLCompDataParseAttributeInfo::HandleSaxAttributeSet(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//                <attributeset name="a0"/>
+	string attributeSetNameStr = aAttribs.getValue(KCompDataParseNodeAttributeInfoAttributeSetAttributeName);
+	iSaxAttributeInfoSelector->iAttributeSetName = attributeSetNameStr;
+	}
+
+
+
+//
+// class TMLCompDataParseLayoutTable
+//
+
+TMLCompDataParseLayoutTable::TMLCompDataParseLayoutTable(TMLCompData* aTables)
+:	TMLCompDataTable(aTables)
+	{
+	}
+
+MSaxLayoutHandler* TMLCompDataParseLayoutTable::HandleSax(const std::string& /*aElement*/, const TAttribs& /*aAttribs*/)
+	{
+	return this;
+	}
+
+
+
+//
+// class TMLCompDataParseLayout
+//
+
+MSaxLayoutHandler* TMLCompDataParseLayout::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if (aElement == KCompDataParseRoot)
+		{
+		// <Layout MasterId="0.6821563014440754" 
+		//		MasterName="m_p" LayoutSetId="1" 
+		//		LayoutName="D_avkon_port" 
+		//		VariantId="0.45128997192758025" 
+		//		variant_name="eur" 
+		//		variant_abbreviation="e" 
+		//		ppi="100.0" 
+		//		ppiUnit="Inches" 
+		//		resolutionHeight="416" 
+		//		resolutionWidth="352" 
+		//		createdOn="2004-08-27 12:37:42.727">
+		iMasterName = aAttribs.getValue(KCompDataParseRootAttributeMasterName);
+		iLayoutName = aAttribs.getValue(KCompDataParseRootAttributeLayoutName);
+		iVariantName = aAttribs.getValue(KCompDataParseRootAttributeVariantName);
+		iResolutionHeight = aAttribs.getValue(KCompDataParseRootAttributeResolutionHeight);
+		iResolutionWidth = aAttribs.getValue(KCompDataParseRootAttributeResolutionWidth);
+		iTimestamp = aAttribs.getValue(KCompDataParseRootAttributeCreatedOn);
+		return this;
+		}
+	else if (aElement == KCompDataParseNodeComponent)
+		{
+		TMLCompDataParseLayoutLine* line = new TMLCompDataParseLayoutLine();
+		line->HandleSax(aElement, aAttribs);
+		iComponents.insert(make_pair(line->iId, line));
+		return line;
+		}
+	else
+		return this;
+	}
+
+
+auto_ptr<TMLCompDataParseLayout> TMLCompDataParseLayout::Parse(const string& aLayName)
+	{
+	auto_ptr<TMLCompDataParseLayout> layout(new TMLCompDataParseLayout);
+	int pos=0;
+	string layName = aLayName;
+	int next = layName.find('+', pos);
+	if (next != string::npos)
+		{
+		throw GeneralErr(layName + " TMLCompDataParseLayout::Parse() - doesn't support multiple files");
+		}
+
+	if (layName.size() >= 2 && layName.substr(0,2) == "-m")
+		{
+		layName = layName.substr(2);
+		layout->iCanBeMirror = true;
+		}
+	layout->iName = layName;
+
+	// SAX parsing method
+	cout << "reading MLCompData(SAX) " << layName << endl;
+	TLayoutSaxParser saxParser(layout.get());
+	saxParser.Parse(layName);
+
+	return layout;
+	}
+
+
+
+TLayoutSaxParser::TLayoutSaxParser(MSaxLayoutHandler* aHandler)
+	{ 
+	iStack.push(aHandler);
+	}
+
+void TLayoutSaxParser::Parse(const std::string& aFileName)
+	{
+	SAX::basic_InputSource<std::string> is(aFileName);
+	SAX::XMLReader<std::string> parser;
+	parser.setContentHandler(*this);
+	parser.setErrorHandler(*this);
+	parser.parse(is);
+	}
+
+void TLayoutSaxParser::startElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                              const std::string& /*qName*/, const SAX::basic_Attributes<std::string>& atts)
+    {
+	MSaxLayoutHandler* handler = iStack.top();
+	if (!handler)
+		throw GeneralErr("SAX: No element handler");
+	MSaxLayoutHandler* next = handler->HandleSax(localName, atts);
+	iStack.push(next);
+    }
+
+void TLayoutSaxParser::endElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                            const std::string& /*qName*/)
+    {
+	iStack.pop();
+	MSaxLayoutHandler* handler = iStack.top();
+	if (handler)
+		handler->HandleSaxEnd(localName);
+    }
+
+
+void TLayoutSaxParser::warning(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TLayoutSaxParser::error(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TLayoutSaxParser::fatalError(const TException& aException)
+    {
+	cerr << aException.what();
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLEqCompData.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,1134 @@
+/*
+* 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 "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: 
+*    
+*
+*/
+
+
+#include "MLEqCompData.h"
+#include "MLEqCompDataParse.h"
+#include "MLEqCompData2DHuiML.h"
+#include "MLAttributes.h"
+#include "FormulaTree.h"
+
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+#include "UsefulDefinitions.h"
+
+#include "Akndef.hrh"
+
+#include <set>
+#include <sstream>
+#include <iostream>
+#include <algorithm>
+
+
+//
+// const data
+//
+
+
+
+const string KEqCompDataKeywordParamLeft = "l";
+const string KEqCompDataKeywordParamTop = "t";
+const string KEqCompDataKeywordParamRight = "r";
+const string KEqCompDataKeywordParamBottom = "b";
+const string KEqCompDataKeywordParamWidth = "w";
+const string KEqCompDataKeywordParamHeight = "h";
+
+const string KEqCompDataPaneOutputOrder[] = 
+	{
+	KEqCompDataKeywordParamLeft,
+	KEqCompDataKeywordParamTop,
+	KEqCompDataKeywordParamRight,
+	KEqCompDataKeywordParamBottom,
+	KEqCompDataKeywordParamWidth,
+	KEqCompDataKeywordParamHeight
+	};
+
+const int KEqCompDataPaneOutputOrderSize = ARRAY_LEN(KEqCompDataPaneOutputOrder);
+
+
+const string KEqCompDataKeywordParamType = "Type";
+const string KEqCompDataKeywordParamFont = "Font";
+const string KEqCompDataKeywordParamNumCols = "NumCols";
+const string KEqCompDataKeywordParamNumRows = "NumRows";
+const string KEqCompDataKeywordScreenContents = "Screen Contents";
+
+const string KEqCompDataKeywordUnderscore = "_";
+const string KEqCompDataKeywordLineNameSuffixGraphic = "g";
+const string KEqCompDataKeywordLineNameSuffixText = "t";
+
+const string KEqCompDataSearchCollectionNumeric = "0123456789";
+const string KEqCompDataBadValue = "Bad Value";
+const string KEqCompDataLayoutEmpty = "ELayoutEmpty";
+const string KEqCompDataUnknown = "unknown";
+
+const string KEqCompDataCellNameLeft("l");
+const string KEqCompDataCellNameRight("r");
+const string KEqCompDataCellNameJustification("J");
+
+const string KAttributeNameStyle1 = "style_1";
+const string KAttributeNameStyle1Plain = "plain";
+const string KAttributeNameStyle1Bold = "bold";
+
+const string KAttributeNameNumberOfColumns = "Number_of_columns";
+const string KAttributeNameNumberOfRows = "Number_of_rows";
+const string KAttributeNameNumberOfRowsColsAuto = "AUTO";
+
+//
+// struct TMLEqCompDataFormula
+//
+TMLEqCompDataFormula::TMLEqCompDataFormula()
+	:
+	iFormulaString(),
+	iZoomId(0),
+	iFormulaTree(NULL)
+	{
+
+	}
+
+TMLEqCompDataFormula::TMLEqCompDataFormula(const TMLEqCompDataFormula& aOther)
+	:
+	iFormulaString(aOther.iFormulaString),
+	iZoomId(aOther.iZoomId),
+	iFormulaTree(aOther.iFormulaTree)
+	{
+	int x = 0;
+	}
+
+const TMLEqCompDataFormula& TMLEqCompDataFormula::operator=(const TMLEqCompDataFormula& aOther)
+	{
+	if(this == &aOther)
+		return aOther;
+
+	iFormulaString = aOther.iFormulaString;
+	iZoomId = aOther.iZoomId;
+
+	if(iFormulaTree)
+		{
+		delete iFormulaTree;
+		iFormulaTree = 0;
+		}
+	iFormulaTree = aOther.iFormulaTree;
+	return *this;
+	}
+
+TMLEqCompDataFormula::TMLEqCompDataFormula(string aFormulaString)
+	:
+	iFormulaString(aFormulaString),
+	iZoomId(0),
+	iFormulaTree(NULL)
+	{
+
+	}
+
+TMLEqCompDataFormula::~TMLEqCompDataFormula()
+	{
+	delete iFormulaTree;
+	iFormulaTree = 0;
+	}
+
+
+bool TMLEqCompDataFormula::operator==(const TMLEqCompDataFormula& aOther) const
+	{
+	return (iFormulaString == aOther.iFormulaString && iZoomId == aOther.iZoomId);
+	}
+
+void TMLEqCompDataFormula::Compile()
+	{
+	if(!iFormulaTree)
+		{
+		iFormulaTree = FormulaTreeNode::Parse(iFormulaString);
+		}
+	else
+		{
+		throw GeneralErr(string("TMLEqCompDataFormula::Compile - formula already parsed."));
+		}
+	}
+
+//
+// TMLEqCompDataValuesOptionSet
+//
+void TMLEqCompDataValuesOptionSet::Compile()
+	{
+	for(iterator pFormula = begin(); pFormula != end(); ++pFormula)
+		{
+		pFormula->Compile();
+		}
+	}
+
+
+//
+// TMLEqCompDataValues
+//
+
+TMLEqCompDataValues::TMLEqCompDataValues()
+	: 
+	iLine(NULL), 
+	iName(KEqCompDataBadValue)
+	{
+	}
+
+TMLEqCompDataValues::TMLEqCompDataValues(TMLEqCompDataLine* aLine)
+	: 
+	iLine(aLine), 
+	iName(aLine->iName)
+	{
+	}
+
+bool TMLEqCompDataValues::operator==(const TMLEqCompDataValues& aOther) const
+	{
+	typedef const vector<TMLEqCompDataFormula> TBase;
+	bool eq =
+		iName == aOther.iName &&
+		(*static_cast<TBase*>(this) == aOther);
+	return eq;
+	}
+
+TMLEqCompDataValues::~TMLEqCompDataValues()
+	{
+	}
+
+bool TMLEqCompDataValues::Merge(TMLEqCompDataLine* aLine, string aName, TMLEqCompDataValues& aOtherValues, bool aMirrorMerge)
+	{
+/*
+	iLine = aLine;
+	iName = aName; // we may be swapping l and r
+
+	// create missing values in this line if needed
+	for (iterator pOtherVal=aOtherValues.begin(); pOtherVal!=aOtherValues.end(); ++pOtherVal)
+		{
+		TMLEqCompDataZoomLevels& otherZoomLevels = pOtherVal->second;
+		TMLEqCompDataZoomLevels& thisZoomLevels = (*this)[pOtherVal->first];
+		thisZoomLevels = otherZoomLevels; // we want exactly the correct number of calcs from the other cell
+		if(aMirrorMerge)
+			{
+			if(iName == KEqCompDataCellNameJustification)
+				{
+				// reverse the justification
+				for(TMLEqCompDataZoomLevels::iterator pCalcs = thisZoomLevels.begin(); pCalcs != thisZoomLevels.end(); ++pCalcs)
+					{
+					TMLEqCompDataCalcs& calcs = pCalcs->second;
+					for(TMLEqCompDataCalcs::iterator pVal = calcs.begin(); pVal != calcs.end(); ++pVal)
+						pVal->second = MirrorJustificationValue(pVal->second);
+					}
+				}
+			}
+		}
+*/
+	return true;
+	}
+
+
+const string KParamLimitNames[] = { "NumCols", "NumRows" };
+const string KHorizNames[] = { "l", "r", "W" };
+const string KVertNames[] = { "t", "b", "H", "Font" };
+const set<string> KParamLimitNamesSet(KParamLimitNames, ARRAY_END(KParamLimitNames));
+const set<string> KHorizNamesSet(KHorizNames, ARRAY_END(KHorizNames));
+const set<string> KVertNamesSet(KVertNames, ARRAY_END(KVertNames));
+
+string TMLEqCompDataValues::MirrorJustificationValue(const string& aValue)
+	{
+	int val = CdlTkUtil::ParseInt(aValue);
+	if(val == ELayoutAlignLeft)
+		val = ELayoutAlignRight;
+	else if(val == ELayoutAlignRight)
+		val = ELayoutAlignLeft;
+	return CdlTkUtil::IntToString(val);
+	}
+
+
+void TMLEqCompDataValues::Compile(int aOptionSetId)
+	{
+	TMLEqCompDataValuesOptionSet& set = iOptionSets[aOptionSetId];
+	set.Compile();
+	}
+
+string TMLEqCompDataValues::CppValue(const string& aValue)
+	{
+	if (aValue.size())
+		return aValue;
+	else
+		return KEqCompDataLayoutEmpty;
+	}
+
+//
+// TMLEqCompDataParentInfoSelector
+//
+TMLEqCompDataParentInfoSelector::TMLEqCompDataParentInfoSelector()
+	{
+
+	}
+
+TMLEqCompDataParentInfoSelector::TMLEqCompDataParentInfoSelector(int aParentId, int aParentVariety)
+	:
+	iParentId(aParentId),
+	iParentVariety(aParentVariety)
+	{
+
+	}
+
+//
+//  TMLEqCompDataParentInfo
+//
+
+TMLEqCompDataParentInfo::TMLEqCompDataParentInfo()
+	:
+	iLine(0)
+	{
+
+	}
+
+TMLEqCompDataParentInfo::TMLEqCompDataParentInfo(TMLEqCompDataLine* aLine)
+	:
+	iLine(aLine)
+	{
+
+	}
+
+TMLEqCompDataParentInfo::~TMLEqCompDataParentInfo()
+	{
+
+	}
+
+void TMLEqCompDataParentInfo::Merge(const TMLEqCompDataParentInfo& aOther)
+	{
+/*
+	for (const_iterator pOtherVariety = aOther.begin(); pOtherVariety != aOther.end(); ++pOtherVariety)
+		{
+		int varietyIndex = pOtherVariety->first;
+		const TMLEqCompDataParentInfoSelector& selector = pOtherVariety->second;
+		insert(make_pair(varietyIndex, selector));
+		}
+*/
+	}
+
+//
+//  TMLEqCompDataLine
+//
+
+TMLEqCompDataLine::TMLEqCompDataLine()
+:	iId(0),
+	iIsUnique(true), 
+	iIsMirroredHorizontally(false),
+	iType(EUnknownComponent),
+	iName(KEqCompDataUnknown),
+	iDrawingOrder(-1),
+	iParentTable(0),
+	iParentInfo(0),
+//	iAttributeInfo(0),
+	iNumCols(1),
+	iNumRows(1),
+	iGlobalIndex(0)
+	{	
+		
+	}
+
+TMLEqCompDataLine::TMLEqCompDataLine(const TMLEqCompDataLine& aOther)
+	{
+	if(this == &aOther)
+		return;
+
+/*
+	*this = aOther; // this will take a copy of the owning pointer
+	if(aOther.iParentInfo) // if it wasn't zero
+		iParentInfo = new TMLEqCompDataParentInfo(*(aOther.iParentInfo)); // we don't want to take ownership, so make our own copy
+	if(aOther.iAttributeInfo) // if it wasn't zero
+		iAttributeInfo = new TMLEqCompDataAttributeInfo(*(aOther.iAttributeInfo)); // we don't want to take ownership, so make our own copy
+*/
+	for (iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		TMLEqCompDataValues& val = pVal->second;
+		val.iLine = this;
+		}
+	iParentTable = 0; // will be set during compile
+	}
+
+bool TMLEqCompDataLine::operator==(const TMLEqCompDataLine& aOther) const
+	{
+	return (Name() == aOther.Name()) && ValuesEqual(aOther);
+	}
+
+TMLEqCompDataLine::~TMLEqCompDataLine()
+	{
+/*
+	delete iParentInfo;
+	delete iAttributeInfo;
+*/
+	}
+
+bool TMLEqCompDataLine::lessthan(TMLEqCompDataLine* aLeft, TMLEqCompDataLine* aRight)
+	{
+	string pureNameLeft = aLeft->NameDiscountingSuffix();
+	string pureNameRight = aRight->NameDiscountingSuffix();
+	if(pureNameLeft != pureNameRight)
+		{
+		return (aLeft->iName) < (aRight->iName);
+		}
+	else
+		{
+		int left = CdlTkUtil::ParseInt(aLeft->NameSuffix());
+		int right = CdlTkUtil::ParseInt(aRight->NameSuffix());
+		return left < right;
+		}
+	}
+
+bool TMLEqCompDataLine::ValuesEqual(const TMLEqCompDataLine& aOther) const
+	{
+	bool eq = true;
+	const_iterator pVal, pOther;
+	for (pVal = begin(), pOther = aOther.begin(); 
+		 eq && pVal != end() && pOther != aOther.end(); 
+		 ++pVal, ++pOther)
+		{
+		eq = (*pVal == *pOther);
+		}
+	eq = eq && pVal == end() && pOther == aOther.end();
+	return eq;
+	}
+
+string TMLEqCompDataLine::Name() const
+	{
+	return iName;
+	}
+
+bool TMLEqCompDataLine::Merge(TMLEqCompDataLine& aOtherLine)
+	{
+/*
+	bool compatible = 
+		(iId == aOtherLine.iId) ||
+		(iName == aOtherLine.iName) ||
+		(iType == aOtherLine.iType);
+	if(compatible)
+		{
+		iDrawingOrder = aOtherLine.iDrawingOrder;
+		iMaxVariety = aOtherLine.iMaxVariety;
+		iIsMirroredHorizontally |= aOtherLine.iIsMirroredHorizontally; // in the case of an elaf layout merging onto an abrw layout, the chirality will be preserved
+		iNeedsOptions |= aOtherLine.iNeedsOptions;
+
+		if(!iParentInfo)
+			{
+			// must be screen...
+			iParentInfo = new TMLEqCompDataParentInfo();
+			}
+		if(aOtherLine.iParentInfo)
+			{
+			iParentInfo->Merge(*(aOtherLine.iParentInfo));
+			}
+
+		if(!iAttributeInfo)
+			{
+			// must be screen...
+			iAttributeInfo = new TMLEqCompDataAttributeInfo();
+			}
+		if(aOtherLine.iAttributeInfo)
+			{
+			iAttributeInfo->Merge(*(aOtherLine.iAttributeInfo));
+			}
+
+		// for the API, we need to know if there are any multi-value components in either orientation
+		iNeedsCols = iNeedsCols || aOtherLine.iNeedsCols;
+		iNeedsRows = iNeedsRows || aOtherLine.iNeedsRows;
+		// however, we want exactly the correct number of calcs from the other cell
+		iNumCols = aOtherLine.iNumCols;
+		iNumRows = aOtherLine.iNumRows;
+
+		// if this line has no values, then we must do a mirror merge
+		bool mirrorMerge = empty() && iIsMirroredHorizontally;
+
+		// create missing values in this line if needed
+		for (TMLEqCompDataLine::iterator pOtherValues=aOtherLine.begin(); pOtherValues!=aOtherLine.end(); ++pOtherValues)
+			{
+			string index = pOtherValues->first;
+			if(mirrorMerge)
+				{
+				// flip left and right
+				if(index == KEqCompDataCellNameLeft)
+					index = KEqCompDataCellNameRight;
+				else if(index == KEqCompDataCellNameRight)
+					index = KEqCompDataCellNameLeft;
+				}
+
+			(*this)[index].Merge(this, index, pOtherValues->second, mirrorMerge);
+			}
+		}
+	return compatible;
+	*/
+	return false;
+	}
+
+TMLAttributeZoomLevels* TMLEqCompDataLine::GetAttributeZoomLevels(string aAttribName, int aVariety)
+	{
+/*
+	TMLAttributeZoomLevels* found = 0;
+	TMLEqCompData& data = *(iParentTable->iTables);
+	TMLAttributes& attributes = *(data.iAttributes);
+	int attribId = attributes.iNames[aAttribName];
+	if(attribId == 0)
+		throw GeneralErr(string("Attribute name not found: ") + aAttribName);
+	// find out from attribute info which attribute set we need
+	// but if there is none specified, we don't need to search
+	if(iAttributeInfo)
+		{
+		TMLEqCompDataAttributeInfoSelector& selector = (*iAttributeInfo)[aVariety];
+		// go to parent straight away, as parent always stores attribute data for its children
+		found = GetParentAttributeZoomLevels(selector.iAttributeSetName, attribId, aVariety);
+		}
+	return found;
+*/
+	return NULL;
+	}
+
+TMLAttributeZoomLevels* TMLEqCompDataLine::GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety)
+	{
+	TMLAttributeZoomLevels* found = NULL;
+	TMLEqCompDataParentInfo::iterator pFoundSelector = iParentInfo->find(aVariety);
+	if(pFoundSelector != iParentInfo->end())
+		{
+		const TMLEqCompDataParentInfoSelector& parentInfoSelector = pFoundSelector->second;
+		if(iParentTable && iParentTable->iParentLine)
+			{
+			found = iParentTable->iParentLine->FindAttributeZoomLevels(aAttribSetName, aAttribId);
+			if(!found)
+				{
+				// recurse to next parent container
+				int variety = parentInfoSelector.iParentVariety;
+				iParentTable->iParentLine->GetParentAttributeZoomLevels(aAttribSetName, aAttribId, variety);
+				}
+			}
+		}
+	return found;
+	}
+
+TMLAttributeZoomLevels* TMLEqCompDataLine::FindAttributeZoomLevels(string aAttribSetName, int aAttribId)
+	{
+	TMLEqCompData& data = *(iParentTable->iTables);
+	TMLAttributes& attributes = *(data.iAttributes);
+	int id = iId;
+	TMLAttributes::iterator foundAttributeSetComponent = attributes.find(id);
+	if(foundAttributeSetComponent != attributes.end())
+		{
+		TMLAttributeSetComponent& component = foundAttributeSetComponent->second;
+		TMLAttributeSet* pSet = component[aAttribSetName];
+		if(pSet)
+			{
+			TMLAttributeSet& attributeSet = *pSet;
+			TMLAttributeSet::iterator foundAttrib = attributeSet.find(aAttribId);
+			if(foundAttrib != attributeSet.end())
+				{
+				return &(foundAttrib->second);
+				}
+			}
+		}
+	return NULL;
+	}
+
+void TMLEqCompDataLine::Compile(int aOptionSetId)
+	{
+	// compile values
+	for(iterator pVal = begin(); pVal != end(); ++pVal)
+		{
+		(pVal->second).Compile(aOptionSetId);
+		}
+	}
+
+bool TMLEqCompDataLine::MatchNameDiscountingSuffix(const TMLEqCompDataLine& aLine) const
+	{
+	// we are trying to compare whether the names are the same apart from a trailing number
+	string pureName = NameDiscountingSuffix();
+	string pureNameOther = aLine.NameDiscountingSuffix();
+	string ending = pureName.substr(pureName.find_last_not_of(KEqCompDataKeywordUnderscore));
+
+	bool namesMatch = (pureName == pureNameOther);
+	bool correctEnding = (ending == KEqCompDataKeywordLineNameSuffixGraphic || ending == KEqCompDataKeywordLineNameSuffixText);
+	return (namesMatch && correctEnding);
+	}
+
+bool TMLEqCompDataLine::MatchType(const TMLEqCompDataLine& aLine) const
+	{
+	// first check that the type is equivalent
+	bool equivalent = false;
+	switch(iType)
+		{
+		case ETextComponent:
+			{
+			if(aLine.iType == ETextComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		case EScreenComponent:
+		case EContainerComponent:
+		case EPaneComponent:
+		case EGraphicComponent:
+			{
+			if(aLine.iType == EScreenComponent
+				|| aLine.iType == EContainerComponent
+				|| aLine.iType == EPaneComponent
+				|| aLine.iType == EGraphicComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		case EUnknownComponent:
+		default:
+			{
+			if(aLine.iType == EUnknownComponent)
+				{
+				equivalent = true;
+				}
+			break;
+			}
+		}
+
+	return equivalent;
+	}
+
+string TMLEqCompDataLine::NameDiscountingSuffix() const
+	{
+	int lastNonNumericPos = iName.find_last_not_of(KEqCompDataSearchCollectionNumeric);
+	int length = lastNonNumericPos + 1;
+	return iName.substr(0, length);
+	}
+
+string TMLEqCompDataLine::NameSuffix() const
+	{
+	int lastNonNumericPos = iName.find_last_not_of(KEqCompDataSearchCollectionNumeric);
+	int suffixPos = lastNonNumericPos + 1;
+	return iName.substr(suffixPos);
+	}
+
+int TMLEqCompDataLine::NumCols() const
+	{
+	return iNumCols;
+	}
+
+int TMLEqCompDataLine::NumRows() const
+	{
+	return iNumRows;
+	}
+
+
+void TMLEqCompDataLine::SetNumCols(int aNumCols)
+	{
+	iNumCols = aNumCols;
+	}
+
+void TMLEqCompDataLine::SetNumRows(int aNumRows)
+	{
+	iNumRows = aNumRows;
+	}
+
+
+//
+// TMLEqCompDataAttributeInfoSelector
+//
+TMLEqCompDataAttributeInfoSelector::TMLEqCompDataAttributeInfoSelector()
+	{
+
+	}
+
+TMLEqCompDataAttributeInfoSelector::TMLEqCompDataAttributeInfoSelector(string aAttributeSetName)
+	:
+	iAttributeSetName(aAttributeSetName)
+	{
+
+	}
+
+//
+//  TMLEqCompDataAttributeInfo
+//
+
+TMLEqCompDataAttributeInfo::TMLEqCompDataAttributeInfo()
+	:
+	iLine(0)
+	{
+
+	}
+
+TMLEqCompDataAttributeInfo::TMLEqCompDataAttributeInfo(TMLEqCompDataLine* aLine)
+	:
+	iLine(aLine)
+	{
+
+	}
+
+TMLEqCompDataAttributeInfo::~TMLEqCompDataAttributeInfo()
+	{
+
+	}
+
+void TMLEqCompDataAttributeInfo::Merge(const TMLEqCompDataAttributeInfo& aOther)
+	{
+	for (const_iterator pOtherVariety = aOther.begin(); pOtherVariety != aOther.end(); ++pOtherVariety)
+		{
+		int varietyIndex = pOtherVariety->first;
+		const TMLEqCompDataAttributeInfoSelector& selector = pOtherVariety->second;
+		insert(make_pair(varietyIndex, selector));
+		}
+	}
+
+
+//
+// TMLEqCompDataTableOptionSet
+//
+TMLEqCompDataTableOptionSet::TMLEqCompDataTableOptionSet()
+	:
+	iOrientation(EMLEqCompDataOptionSetOrientationUndefined)
+	{
+	
+	}
+
+TMLEqCompDataTableOptionSet::TMLEqCompDataTableOptionSet(const TMLEqCompDataTableOptionSet& aOther)
+	:
+	iOrientation(aOther.iOrientation)
+	{
+	for(const_iterator pOtherLines = aOther.begin(); pOtherLines != aOther.end(); ++pOtherLines)
+		{
+		push_back(*pOtherLines);
+		}
+	}
+
+TMLEqCompDataTableOptionSet::~TMLEqCompDataTableOptionSet()
+	{
+	// don't delete pointers to lines, as they are not owned
+	clear();
+	}
+
+void TMLEqCompDataTableOptionSet::Compile(int aOptionSetId)
+	{
+	for (iterator pLine = begin(); pLine != end(); ++pLine)
+		{
+		(*pLine)->Compile(aOptionSetId);
+		}
+	}
+
+TMLEqCompDataLine* TMLEqCompDataTableOptionSet::FindLine(int aId) const
+	{
+	for(const_iterator pLine = begin(); pLine != end(); ++pLine)
+		{
+		TMLEqCompDataLine* line = *pLine;
+		if(line)
+			{
+			if(line->iId == aId)
+				return line;
+			}
+		}
+	return NULL;
+	}
+
+//
+// TMLEqCompDataTable
+//
+
+TMLEqCompDataTable::TMLEqCompDataTable(TMLEqCompData* aTables)
+	: 
+	iTables(aTables), 
+	iParentLine(NULL), 
+	iId(0)
+	{
+	}
+
+TMLEqCompDataTable::TMLEqCompDataTable(TMLEqCompData* aTables, const TMLEqCompDataTable& aOther)
+	: 
+	iTables(aTables), 
+	iParentLine(NULL), 
+	iParentName(aOther.iParentName),
+  	iId(aOther.iId)
+	{
+	for (const_iterator pOptionSet = aOther.begin(); pOptionSet != aOther.end(); ++pOptionSet)
+		{
+		insert(make_pair(pOptionSet->first, TMLEqCompDataTableOptionSet(pOptionSet->second)));
+		}
+	}
+
+TMLEqCompDataTable::~TMLEqCompDataTable()
+	{
+	// no need to delete lines, as they are not owned.
+	}
+
+string TMLEqCompDataTable::Name()
+	{
+	return iName;
+	}
+
+// @todo this will need to be modified to allow for searching for a line at a specific option set number
+TMLEqCompDataLine* TMLEqCompDataTable::FindLine(const string& aName)
+	{
+/*
+	for (iterator pLine = begin(); pLine != end(); ++pLine)
+		{
+		TMLEqCompDataLine& line = **pLine;
+		if (line.Name() == aName)
+			return *pLine;
+		}
+*/
+	return 0;
+	}
+
+void TMLEqCompDataTable::Merge(TMLEqCompDataTable& aOther)
+	{
+/*
+	for (iterator pOtherLine = aOther.begin(); pOtherLine != aOther.end(); )
+		{
+        TMLEqCompDataLine* found = FindLine((*pOtherLine)->Name());
+        if(found)
+            {
+            found->Merge(**pOtherLine);
+            delete *pOtherLine;
+			pOtherLine = aOther.erase(pOtherLine);
+			}
+		else
+            {
+			push_back(*pOtherLine);
+			(*pOtherLine)->iParentTable = this;
+			pOtherLine = aOther.erase(pOtherLine);
+			}
+		}
+*/
+	}
+
+
+void TMLEqCompDataTable::Compile()
+	{
+//	SetDefaultColumnNames();
+//	sort(begin(), end(), TMLEqCompDataLine::lessthan);	
+
+	for (iterator pOptionSet = begin(); pOptionSet != end(); ++pOptionSet)
+		{
+		pOptionSet->second.Compile(pOptionSet->first);
+		}
+	}
+
+
+
+const string KValueNames[] = { "Font", "C", "l", "r", "W", "J", "t", "r", "b", "H" };
+const set<string> KValueNamesSet(KValueNames, ARRAY_END(KValueNames));
+
+bool TMLEqCompDataTable::IsValueColumn(string aName)
+	{
+	return KValueNamesSet.find(aName) != KValueNamesSet.end();
+	}
+
+const string KNumericNames[] = { "C", "l", "r", "W", "t", "r", "b", "H" };
+const set<string> KNumericNamesSet(KNumericNames, ARRAY_END(KNumericNames));
+
+bool TMLEqCompDataTable::IsNumericColumn(string aName)
+	{
+	return KNumericNamesSet.find(aName) != KNumericNamesSet.end();
+	}
+
+const string KHorizontalColumnNames[] = { "l", "r", "W"};
+const set<string> KHorizontalNamesSet(KHorizontalColumnNames, ARRAY_END(KHorizontalColumnNames));
+
+bool TMLEqCompDataTable::IsHorizontalColumn(string aName)
+	{
+	return KHorizontalNamesSet.find(aName) != KHorizontalNamesSet.end();
+	}
+
+const string KVerticalColumnNames[] = {"t", "b", "H" };
+const set<string> KVerticalNamesSet(KVerticalColumnNames, ARRAY_END(KVerticalColumnNames));
+
+bool TMLEqCompDataTable::IsVerticalColumn(string aName)
+	{
+	return KVerticalNamesSet.find(aName) != KVerticalNamesSet.end();
+	}
+
+
+const string KPaneColumnNames[] = {"Item", "C", "l", "t", "r", "b", "W", "H", "Remarks"};
+const string KGraphicColumnNames[] = {"Item", "C", "l", "t", "r", "b", "W", "H", "Remarks"};
+const string KTextColumnNames[] = {"Font", "C", "l", "r", "t", "b", "W", "H", "J", "Remarks"};
+
+void TMLEqCompDataTable::SetDefaultColumnNames()
+	{
+	iColumnNames.clear();
+	iColumnNames.insert(iColumnNames.end(), KPaneColumnNames, ARRAY_END(KTextColumnNames)); // superset
+	}
+
+
+// 
+// TMLEqListComponent
+//
+TMLEqListComponent::TMLEqListComponent()
+	: 
+	iId(-1),
+	iName("badName")
+	{
+
+	}
+
+//
+// struct TMLEqParChildComponent
+//
+	TMLEqParChildComponent::TMLEqParChildComponent()
+	:
+	iId(-1),
+	iParentId(0)
+	{
+
+	}
+
+
+//
+// TMLEqCompData
+//
+
+TMLEqCompData::TMLEqCompData()
+	: 
+	iCanBeMirror(false),
+	iIsBaseInstance(false),
+	iAttributes(0)
+	{
+	}
+
+TMLEqCompData::TMLEqCompData(const TMLEqCompData& aOther)
+	{
+	*this = aOther;
+	}
+
+TMLEqCompData& TMLEqCompData::operator=(const TMLEqCompData& aOther)
+	{
+	if (this != &aOther)
+		{
+		iName = aOther.iName;
+		iCanBeMirror = aOther.iCanBeMirror;
+		for (const_iterator pTab = aOther.begin(); pTab != aOther.end(); ++pTab)
+			push_back(new TMLEqCompDataTable(this, **pTab));
+		Compile();
+		}
+	return *this;
+	}
+
+TMLEqCompData::~TMLEqCompData()
+	{
+	for (iterator pTab = begin(); pTab != end(); ++pTab)
+		delete *pTab;
+	DeleteComponents();
+	delete iAttributes;
+	}
+
+TMLEqCompDataLine* TMLEqCompData::FindComponent(const string& aName) const
+	{
+	for (TMLEqCompDataComponents::const_iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLEqCompDataLine* line = pComp->second;
+		if (line->Name() == aName)
+			return line;
+		}
+
+	return 0;
+	}
+
+TMLEqCompDataLine* TMLEqCompData::FindLine(const string& aName) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		TMLEqCompDataLine* line = (*pTab)->FindLine(aName);
+		if (line)
+			return line;
+		}
+
+	return 0;
+	}
+
+TMLEqCompDataTable* TMLEqCompData::FindTable(const string& aName) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		if ((*pTab)->Name() == aName)
+			return *pTab;
+		}
+
+	return 0;
+	}
+
+TMLEqCompDataTable* TMLEqCompData::FindTable(int aId) const
+	{
+	for (const_iterator pTab = begin(); pTab != end(); ++pTab)
+		{
+		if ((*pTab)->iId == aId)
+			return *pTab;
+		}
+
+	return 0;
+	}
+
+void TMLEqCompData::Merge(TMLEqCompData& aOther)
+	{
+	iName = aOther.iName;
+	iCanBeMirror |= aOther.iCanBeMirror; // in the case of an elaf layout merging onto an abrw layout, the chirality will be preserved
+	MergeComponents(aOther);
+	}
+
+void TMLEqCompData::MergeComponents(TMLEqCompData& aOther)
+    {
+	for (TMLEqCompDataComponents::iterator pOtherLine = aOther.iComponents.begin(); pOtherLine != aOther.iComponents.end(); ++pOtherLine)
+		{
+		TMLEqCompDataLine& otherLine = *(pOtherLine->second);
+        TMLEqCompDataLine* found = FindComponent(otherLine.iName);
+        if(found)
+			{
+			found->Merge(otherLine);
+			}
+		else
+			{
+			TMLEqCompDataLine* newLine = new TMLEqCompDataLine(otherLine);
+			iComponents.insert(make_pair(otherLine.iId, newLine));
+			}
+		}
+	}
+
+void TMLEqCompData::Compile()
+	{
+	UpdateNames();
+	CreateTables();
+
+	// now add a special table for the screen contents
+	TMLEqCompDataTable* topTab = new TMLEqCompDataTable(this);
+	topTab->iId = -1;
+	topTab->iName = KEqCompDataKeywordScreenContents;
+
+	// then insert each line into its parent
+	for (TMLEqCompDataComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLEqCompDataLine& line = *(pComp->second);
+		if(line.iType == TMLEqCompDataLine::EScreenComponent)
+			{
+			line.iParentTable = topTab;
+			TMLEqCompDataTableOptionSet& optionSet = (*topTab)[0];
+			optionSet.push_back(&line);
+			}
+		else
+			{
+			bool parentFound = false;
+			TMLEqParChildComponent* parChild = iParChildComponents[line.iId];
+			int parentId = parChild->iParentId;
+			if(parentId != 0)
+				{
+				TMLEqCompDataTable* parentTable = FindTable(parentId);
+				TMLEqCompDataLine* parentLine = iComponents[parentId];
+				if(parentTable)
+					{
+					line.iParentTable = parentTable;
+
+					// iterate through the line and populate the table option sets as needed
+					for(TMLEqCompDataLine::iterator pValues = line.begin(); pValues != line.end(); ++pValues)
+						{
+						TMLEqCompDataValues& values = pValues->second;
+						TMLEqCompDataValuesOptionSets& sets = values.iOptionSets;
+						for(TMLEqCompDataValuesOptionSets::iterator pValuesOptionSet = sets.begin(); pValuesOptionSet != sets.end(); ++pValuesOptionSet)
+							{
+							TMLEqCompDataValuesOptionSet& valuesSet = pValuesOptionSet->second;
+							int optionId = pValuesOptionSet->first;
+							TMLEqCompDataTableOptionSet& tableSet = (*parentTable)[optionId]; // constructs if not yet present
+							if(tableSet.iOrientation != valuesSet.iOrientation)
+								tableSet.iOrientation = valuesSet.iOrientation;
+							
+							TMLEqCompDataLine* lineInTable = tableSet.FindLine(line.iId);
+							if(!lineInTable)
+								{
+								// make one
+								tableSet.push_back(&line);
+								}
+							}
+						}
+
+					// copy the pointer from the components table
+//					parentTable->insert(make_pair(line.iId, &line));
+					parentFound = true;
+
+					// now insert the table into its place in the tree
+					parentTable->iParentLine = iComponents[parentId];
+					}
+				else
+					{
+					parentFound = false;
+					}
+				}
+			if(!parentFound)
+				{
+                string errorText = string(" TMLEqCompData::Compile() - can't find parent component: ");
+				errorText += CdlTkUtil::IntToString(parentId);
+				throw GeneralErr(errorText);
+				}
+			}		
+		}	
+	push_back(topTab);
+	
+	// now compile the tables
+	iterator pTab;
+	for (pTab = begin(); pTab != end(); ++pTab)
+		(*pTab)->Compile();
+
+	// now sort the tables
+//	sort(begin(), end(), TMLEqCompDataTable::lessthan);	
+	}
+
+void TMLEqCompData::UpdateNames()
+	{
+	// from the list of components, get the name of each line from the list
+	for (TMLEqCompDataComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLEqCompDataLine* line = pComp->second;
+		TMLEqListComponent* pListComp = iListComponents[line->iId];
+		line->iName = pListComp->iName;
+		}
+
+	}
+
+void TMLEqCompData::CreateTables()
+	{
+	// from the list of components, first create a table for each pane
+	for (TMLEqCompDataComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		{
+		TMLEqCompDataLine& line = *(pComp->second);
+		switch(line.iType)
+			{
+			case TMLEqCompDataLine::EScreenComponent:
+			case TMLEqCompDataLine::EContainerComponent:
+			case TMLEqCompDataLine::EPaneComponent:
+				{
+				TMLEqCompDataTable* tab = new TMLEqCompDataTable(this);
+				tab->iId = line.iId;
+				tab->iName = line.iName;
+				push_back(tab);
+				break;
+				}
+			case TMLEqCompDataLine::EGraphicComponent:
+			case TMLEqCompDataLine::ETextComponent:
+				{
+				// text and graphic components are not panes 
+				// and are therefore not represented in our internal object model as tables
+				break;
+				}
+			default:
+				{
+				cout << "TMLEqCompData::CreateTables() - uncategorised component\n";
+				break;
+				}
+			}	
+		}
+	}
+
+void TMLEqCompData::DeleteComponents()
+	{
+	for (TMLEqCompDataComponents::iterator pComp = iComponents.begin(); pComp != iComponents.end(); ++pComp)
+		delete pComp->second;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLEqCompData2DHuiML.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,585 @@
+/*
+* 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 "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:  
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "MLEqCompData2DHuiML.h"
+#include "MLEqCompDataParse.h"
+#include "LayoutCompilerErr.h"
+#include "FormulaTree.h"
+
+#include <cdlcompilertoolkit/cdltkprocess.h>
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+
+#include "CodeGenConsts.h"
+
+
+using namespace std;
+
+typedef LayoutProcessArgsErr<MLEqCompDataToDHuiML> MLEqCompDataToDHuiMLArgsErr;
+
+// constants
+
+const string KCompDataFileNameSuffix("compData");
+const string KAttributesFileNameSuffix("attributes");
+
+
+//
+// class TEqLayoutSaxWriter
+//
+
+
+class TEqLayoutSaxWriter
+	{
+public:
+	enum 
+		{
+		KIndentSize=4
+		};
+public:
+	TEqLayoutSaxWriter(ofstream& aStream);
+    void StartDocument();
+    void EndDocument();
+	void OpenStartElement(const string& aLocalName);
+	void CloseStartElement();
+	void CloseAndEndStartElement();
+	void EndElement(const string& aLocalName);
+	void Attribute(const string& aLocalName, const string& aValue);
+	void Comment(const string& aComment);
+
+private:
+	void Indent();
+	void IncreaseIndentLevel();
+	void DecreaseIndentLevel();
+private:
+	ofstream& iStream;
+	int iIndentLevel;
+	};
+
+TEqLayoutSaxWriter::TEqLayoutSaxWriter(ofstream& aStream)
+	: 
+	iStream(aStream),
+	iIndentLevel(0)
+	{
+
+	};
+
+void TEqLayoutSaxWriter::StartDocument()
+	{
+	Indent();
+	iStream << string("<xmluiml xmlns=\"http://www.series60.com/xml/xmluiml/1\">") << endl;
+	IncreaseIndentLevel();
+	}
+
+void TEqLayoutSaxWriter::EndDocument()
+	{
+	DecreaseIndentLevel();
+	Indent();
+	iStream << string("</xmluiml>") << endl;
+	}
+
+//void TEqLayoutSaxWriter::StartElement(const string& /*namespaceURI*/, const string& localName /*, const string& qName*/ /*, const AttributesT& atts*/)
+void TEqLayoutSaxWriter::OpenStartElement(const string& aLocalName)
+	{
+	Indent();
+	iStream << "<" << aLocalName;
+	IncreaseIndentLevel();
+	}
+
+void TEqLayoutSaxWriter::CloseStartElement()
+	{
+	iStream << ">" << endl;
+	}
+
+void TEqLayoutSaxWriter::CloseAndEndStartElement()
+	{
+	iStream << " />" << endl;
+	DecreaseIndentLevel();
+	}
+
+void TEqLayoutSaxWriter::EndElement(const string& aLocalName)
+	{
+	DecreaseIndentLevel();
+	Indent();
+	iStream << "</" << aLocalName << ">" << endl;
+	}
+
+void TEqLayoutSaxWriter::Attribute(const string& aLocalName, const string& aValue)
+	{
+	iStream << " " << aLocalName << "=\"" << aValue << "\"";
+	}
+
+void TEqLayoutSaxWriter::Comment(const string& aComment)
+	{
+	iStream << "<!--  " << aComment << " -->" << endl;
+	}
+
+void TEqLayoutSaxWriter::Indent()
+	{
+	stringstream ss;
+	int max = iIndentLevel * KIndentSize;
+	for(int count = 0; count < max; count++)
+		{
+		ss << " ";
+		}
+	iStream << ss.str();
+	}
+
+void TEqLayoutSaxWriter::IncreaseIndentLevel()
+	{
+	if(iIndentLevel > 1000)
+		throw GeneralErr("TEqLayoutSaxWriter::DecreaseIndentLevel - nesting inconsistency");
+	iIndentLevel++;
+	}
+
+void TEqLayoutSaxWriter::DecreaseIndentLevel()
+	{
+	if(iIndentLevel == 0)
+		throw GeneralErr("TEqLayoutSaxWriter::DecreaseIndentLevel - nesting inconsistency");
+	iIndentLevel--;
+	}
+
+
+
+// 
+// MLEqCompDataToDHuiML
+//
+
+int MLEqCompDataToDHuiML::Process(const vector<string>& args)
+	{
+	int numExpectedArgs = 5;
+	int numArgs = args.size();
+	if(numArgs < numExpectedArgs)
+		throw MLEqCompDataToDHuiMLArgsErr();
+	
+    int arg = 2;
+	string listName = args[arg++];
+	string compDataName = args[arg++];
+	string parChildName = args[arg++];
+	string dhuimlName = args[arg++];
+
+	auto_ptr<TMLEqCompDataParseLayout> layoutParse = TMLEqCompDataParseLayout::Parse(listName, compDataName, parChildName);
+	auto_ptr<TMLEqCompData> layout(layoutParse.get());
+	layoutParse.release();
+
+	TMLEqCompData* theLayout = layout.get();
+	theLayout->Compile();
+
+	cout << "writing dhuiml file " << dhuimlName << endl;
+	ofstream dhuiml(dhuimlName.c_str());
+
+	int KIndent = 4;
+	TEqLayoutSaxWriter saxWriter(dhuiml);
+	saxWriter.StartDocument();
+
+	stringstream comment1;
+	comment1 << "Generated from list: " << listName;
+	saxWriter.Comment(comment1.str());
+
+	stringstream comment2;
+	comment2 << "Generated from component data: " << compDataName;
+	saxWriter.Comment(comment2.str());
+
+	stringstream comment3;
+	comment3 << "Generated from parent child data: " << parChildName;
+	saxWriter.Comment(comment3.str());
+
+	LayoutTablesToDeclarative(saxWriter, *theLayout);
+    
+	saxWriter.EndDocument();
+
+	return 0;
+	}
+
+void MLEqCompDataToDHuiML::ShowHelp(ostream& stream)
+	{
+	stream << "MLEqCompData2DHuiML <MLEqCompListName> <MLEqCompDataName> <MLEqParChildName> <DHuiMLName>" << endl;
+    stream << "  e.g. from \\S60\\AknLayout2\\group run " << endl;
+    stream << "  aknlayoutcompiler MLEqCompData2DHuiML " << endl;
+	stream << "      ..\\..\\xml_master\\xml\\m_p_30\\m_p_30_list.xml " << endl;
+	stream << "      ..\\..\\xml_master\\xml\\m_p_30\\m_p_30\\0.161093285736413\\eur_compData.xml " << endl;
+	stream << "      ..\\..\\xml_master\\xml\\m_p_30\\m_p_30\\0.161093285736413\\eur_parChildRelation.xml " << endl;
+	stream << "      ..\\generated_declarative\\lct_avkon.dhuiml" << endl;
+	}
+
+void MLEqCompDataToDHuiML::LayoutTablesToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompData& aLayout)
+	{
+	// first the tables are output
+	for (TMLEqCompData::const_iterator pTab = aLayout.begin(); pTab != aLayout.end(); ++pTab)
+		{
+		AddTableToDeclarative(aSaxWriter, **pTab);
+		}
+	}
+
+void MLEqCompDataToDHuiML::LayoutComponentsToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompData& aLayout)
+	{
+	// then the individual components are output
+	for (TMLEqCompData::TMLEqCompDataComponents::const_iterator pLine = aLayout.iComponents.begin(); pLine != aLayout.iComponents.end(); ++pLine)
+		{
+		// @todo this may be needed if the components are to be written out separately from the tables
+		}
+	}
+
+
+const string KDHuiMLLayoutmanager("layoutmanager");
+const string KDHuiMLLayoutmanagerId("id");
+const string KDHuiMLLayoutmanagerName("name");
+const string KDHuiMLOptionSet("optionset");
+const string KDHuiMLOptionSetId("id");
+const string KDHuiMLOptionSetOrientationPortrait("portrait");
+const string KDHuiMLOptionSetOrientationLandscape("landscape");
+const string KDHuiMLOptionSetOrientationTrue("true");
+const string KDHuiMLOptionSetOrientationFalse("false");
+
+void MLEqCompDataToDHuiML::AddTableToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataTable& aTable)
+	{
+	if(aTable.size() == 0)
+		return;
+	
+//	<layoutmanager id="1233" name="listscroll_app_pane">
+//		<optionset id="0" portrait="true" landscape="false">
+//			<lctcomponent id="1234" name="grid_app_pane">
+
+	aSaxWriter.OpenStartElement(KDHuiMLLayoutmanager);
+	aSaxWriter.Attribute(KDHuiMLLayoutmanagerId, CdlTkUtil::IntToString(aTable.iId));
+	aSaxWriter.Attribute(KDHuiMLLayoutmanagerName, aTable.iName);
+	aSaxWriter.CloseStartElement();
+
+	// iterate through option sets
+	for(TMLEqCompDataTable::iterator pOptionSet = aTable.begin(); pOptionSet != aTable.end(); ++pOptionSet)
+		{
+		int optionSetId = pOptionSet->first;
+		TMLEqCompDataTableOptionSet& optionSet = pOptionSet->second;
+		aSaxWriter.OpenStartElement(KDHuiMLOptionSet);
+		aSaxWriter.Attribute(KDHuiMLOptionSetId, CdlTkUtil::IntToString(optionSetId));
+
+		string isPortrait = (optionSet.iOrientation & EMLEqCompDataOptionSetOrientationPortrait) ? KDHuiMLOptionSetOrientationTrue : KDHuiMLOptionSetOrientationFalse;
+		aSaxWriter.Attribute(KDHuiMLOptionSetOrientationPortrait, isPortrait);
+		string isLandscape = (optionSet.iOrientation & EMLEqCompDataOptionSetOrientationLandscape) ? KDHuiMLOptionSetOrientationTrue : KDHuiMLOptionSetOrientationFalse;
+		aSaxWriter.Attribute(KDHuiMLOptionSetOrientationLandscape, isLandscape);
+
+		aSaxWriter.CloseStartElement();
+
+		for(TMLEqCompDataTableOptionSet::iterator pLine = optionSet.begin(); pLine != optionSet.end(); ++pLine)
+			{
+			AddLineToDeclarative(aSaxWriter, **pLine, optionSetId);
+			}
+		aSaxWriter.EndElement(KDHuiMLOptionSet);
+		}
+
+	aSaxWriter.EndElement(KDHuiMLLayoutmanager);
+	}
+
+
+const string KDHuiMLLCTComponent("lctcomponent");
+const string KDHuiMLLCTComponentId("id");
+const string KDHuiMLLCTComponentName("name");
+const string KDHuiMLAlfLayout("alflayout");
+const string KDHuiMLAlfLayoutType("type");
+const string KDHuiMLAlfLayoutTypeAnchor("anchor");
+
+void MLEqCompDataToDHuiML::AddLineToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataLine& aLine, int aOptionSetId)
+	{
+	// beginning of component
+
+//		<lctcomponent id="1234" name="grid_app_pane">
+//			<alflayout type="anchor">
+
+	aSaxWriter.OpenStartElement(KDHuiMLLCTComponent);
+	aSaxWriter.Attribute(KDHuiMLLCTComponentId, CdlTkUtil::IntToString(aLine.iId));
+	aSaxWriter.Attribute(KDHuiMLLCTComponentName, aLine.iName);
+	aSaxWriter.CloseStartElement();
+
+	aSaxWriter.OpenStartElement(KDHuiMLAlfLayout);
+	aSaxWriter.Attribute(KDHuiMLAlfLayoutType, KDHuiMLAlfLayoutTypeAnchor);
+	aSaxWriter.CloseStartElement();
+
+	const string* outputOrder =  KEqCompDataPaneOutputOrder;
+	const int outputSize = KEqCompDataPaneOutputOrderSize;
+	vector<string> cellOrder(outputOrder, outputOrder + outputSize);
+
+	for (vector<string>::iterator pCell = cellOrder.begin(); pCell != cellOrder.end(); ++pCell)
+		{
+		string cellName = *pCell;
+		AddCellToDeclarative(aSaxWriter, aLine[cellName], cellName, aOptionSetId);
+		}
+
+	aSaxWriter.EndElement(KDHuiMLAlfLayout);
+	aSaxWriter.EndElement(KDHuiMLLCTComponent);
+	}
+
+const string KDHuiMLAnchor("anchor");
+const string KDHuiMLAnchorOrdinal("ordinal");
+const string KDHuiMLAnchorType("type");
+const string KDHuiMLAnchorTypePrefix("EAlfAnchorType"); // not currently used, to save disk space
+const string KDHuiMLAnchorAttachmentOrigin("attachmentOrigin");
+const string KDHuiMLAnchorAttachmentOriginPrefix("EAlfAnchorAttachmentOrigin");  // not currently used, to save disk space
+const string KDHuiMLAnchorAttachmentOrdinal("attachmentOrdinal");
+const string KDHuiMLAnchorAttachmentOrdinalAttachToParent("P");
+const string KDHuiMLAnchorOffset("offset");
+const string KDHuiMLAnchorOffsetMagnitude("magnitude");
+const string KDHuiMLAnchorOffsetUnit("unit");
+const string KDHuiMLAnchorOffsetUnitPixel("S60");
+
+void MLEqCompDataToDHuiML::AddCellToDeclarative(TEqLayoutSaxWriter& aSaxWriter, TMLEqCompDataValues& aValues, const string& aCellName, int aOptionSetId)
+	{
+//				<anchor 
+//					ordinal="0" // don't need this, as declarative can calculate drawing order at runtime
+//					type="EAlfAnchorTypeLeft"
+//					attachmentOrigin="EAlfAnchorAttachmentOriginLeft"
+//					attachmentOrdinal="EAlfAnchorAttachToParent">
+//			        <offset 
+//						magnitude="20"
+//						unit="EAlfUnitPixel" 
+//						zoomId = "233" />
+//					<formula formulaStr=""> // @todo this is temporary whilst equation evaluation is developed
+//						...
+//					</formula>
+//				</anchor>
+
+	bool validCell(false);
+	TMLEqCompDataFormula* formula = NULL;
+	TMLEqCompDataValuesOptionSet& optionSet = aValues.iOptionSets[aOptionSetId];
+	// always assume it's the first and only forumla
+	if(optionSet.size() > 0)
+		{
+		formula = &(optionSet[0]);
+		if(!formula->iFormulaString.empty())
+			{
+			validCell = true;
+			}
+		}
+
+	if(!validCell)
+		return;
+
+	aSaxWriter.OpenStartElement(KDHuiMLAnchor);
+
+//		aSaxWriter.Attribute(KDHuiMLAnchorOrdinal, 0); // don't need this, as declarative can calculate drawing order at runtime
+
+	string anchorType = aCellName;
+	ConvertPositionValueStr(anchorType);
+	aSaxWriter.Attribute(KDHuiMLAnchorType, anchorType); 
+
+	// @todo for now, always attach to the same side, but need to calculate this for e.g. orthogonal anchors
+	aSaxWriter.Attribute(KDHuiMLAnchorAttachmentOrigin, anchorType);
+
+	aSaxWriter.Attribute(KDHuiMLAnchorAttachmentOrdinal, KDHuiMLAnchorAttachmentOrdinalAttachToParent);
+	
+	aSaxWriter.CloseStartElement();
+
+		{
+		aSaxWriter.OpenStartElement(KDHuiMLAnchorOffset);
+		aSaxWriter.Attribute(KDHuiMLAnchorOffsetMagnitude, "0"); // @todo, replace with value in units!
+		aSaxWriter.Attribute(KDHuiMLAnchorOffsetUnit, KDHuiMLAnchorOffsetUnitPixel); // @todo, replace with s60 units when supported
+		aSaxWriter.CloseAndEndStartElement();
+		}
+
+	AddFormulaToDeclarative(aSaxWriter, *formula);
+	
+	aSaxWriter.EndElement(KDHuiMLAnchor);
+	}
+
+
+//
+// this is all temporary, to illustrate equation parsing
+//
+
+
+const string KDHuiMLAnchorFormula("formula");
+const string KDHuiMLAnchorFormulaString("formulastr");
+const string KDHuiMLAnchorFormulaNode("node");
+const string KDHuiMLAnchorFormulaNodeType("type");
+const string KDHuiMLAnchorFormulaNodeValue("value");
+
+
+void Print(TEqLayoutSaxWriter& aSaxWriter, const FormulaTreeNode& aNode)
+	{
+	aSaxWriter.OpenStartElement(KDHuiMLAnchorFormulaNode);
+	stringstream ss;
+
+	switch (aNode.Type())
+		{
+		case FormulaTreeNode::EReal:		// Double() = the number
+			ss << aNode.Real();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "real");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EInt:			// Int() = the number
+			ss << aNode.Int();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "int");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::ECell:			// Char() = cell name
+			ss << aNode.Char();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "cell");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EParent:		// nothing special
+			ss << aNode.Char();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "parent");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EParentCell:	// Char() = parent cell name
+			ss << aNode.Char();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "parent_cell");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::ETableCell:		// Double() = target table
+			ss << aNode.Real();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "table_cell");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EComponent:		// Double() = component id, [0] = cell name
+			ss << aNode.Real();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "component");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			break;
+		case FormulaTreeNode::EAbsolute:		// Text() = whole thing, [0], [1] = real components, [2] = cell name
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "absolute_cell_ref");
+//			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			Print(aSaxWriter, aNode[1]);
+			Print(aSaxWriter, aNode[2]);
+			break;
+		case FormulaTreeNode::EUnits:			// Double() = units
+			ss << aNode.Real();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "units");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EConstant:		// Double() = constant
+			ss << aNode.Real();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "constant");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EAttribute:		// Int() = attribute
+			ss << aNode.Int();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "attribute");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			break;
+		case FormulaTreeNode::EMystery:		// Text() = whole thing, [0], [1] = int components
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "mystery");
+//			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			Print(aSaxWriter, aNode[1]);
+			break;
+		case FormulaTreeNode::EFunction:		// Text() = function name, [0] = parameter
+			ss << aNode.Text();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "function");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			break;
+		case FormulaTreeNode::EArithmetic:	// Char() = arithmetic operator, [0], [1] = sub expressions
+			ss << aNode.Char();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "arithmetic");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			Print(aSaxWriter, aNode[1]);
+			break;
+		case FormulaTreeNode::ECondition:		// Text() = comparison operator, [0], [1] = sub expressions
+			ss << aNode.Text();
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "condition");
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			Print(aSaxWriter, aNode[1]);
+			break;
+		case FormulaTreeNode::EConditional:	// no content, [0] = condition, [1] = then expression, [2] = else expression
+			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeType, "if_then_else");
+//			aSaxWriter.Attribute(KDHuiMLAnchorFormulaNodeValue, ss.str());
+			aSaxWriter.CloseStartElement();
+			Print(aSaxWriter, aNode[0]);
+			Print(aSaxWriter, aNode[1]);
+			Print(aSaxWriter, aNode[2]);
+			break;
+		}
+	aSaxWriter.EndElement(KDHuiMLAnchorFormulaNode);
+	}
+
+
+void MLEqCompDataToDHuiML::AddFormulaToDeclarative(TEqLayoutSaxWriter& aSaxWriter, const TMLEqCompDataFormula& aFormula)
+	{
+//		<formula formulaStr=""> // @todo this is temporary whilst equation evaluation is developed
+//			<node type="123" value="456"/>
+//		</formula>		
+	aSaxWriter.OpenStartElement(KDHuiMLAnchorFormula);
+	aSaxWriter.Attribute(KDHuiMLAnchorFormulaString, aFormula.iFormulaString); // @todo, replace with expanded formula xml
+	aSaxWriter.CloseStartElement();
+
+	if(aFormula.iFormulaTree)
+		{
+		Print(aSaxWriter, *(aFormula.iFormulaTree));
+		}
+
+	aSaxWriter.EndElement(KDHuiMLAnchorFormula);
+	}
+
+extern const string KEqCompDataKeywordParamLeft;
+extern const string KEqCompDataKeywordParamTop;
+extern const string KEqCompDataKeywordParamRight;
+extern const string KEqCompDataKeywordParamBottom;
+extern const string KEqCompDataKeywordParamWidth;
+extern const string KEqCompDataKeywordParamHeight;
+
+const string KDHuiMLAnchorLeft("left");
+const string KDHuiMLAnchorTop("top");
+const string KDHuiMLAnchorRight("right");
+const string KDHuiMLAnchorBottom("bottom");
+const string KDHuiMLAnchorWidth("width");
+const string KDHuiMLAnchorHeight("height");
+
+void MLEqCompDataToDHuiML::ConvertPositionValueStr(std::string& aValueStr)
+	{
+	if(aValueStr == KEqCompDataKeywordParamLeft) 
+		aValueStr = KDHuiMLAnchorLeft;
+	else if(aValueStr == KEqCompDataKeywordParamTop) 
+		aValueStr = KDHuiMLAnchorTop;
+	else if(aValueStr == KEqCompDataKeywordParamRight) 
+		aValueStr = KDHuiMLAnchorRight;
+	else if(aValueStr == KEqCompDataKeywordParamBottom) 
+		aValueStr = KDHuiMLAnchorBottom;
+	else if(aValueStr == KEqCompDataKeywordParamWidth) 
+		aValueStr = KDHuiMLAnchorWidth;
+	else if(aValueStr == KEqCompDataKeywordParamHeight) 
+		aValueStr = KDHuiMLAnchorHeight;
+	else
+		aValueStr = KDHuiMLAnchorLeft;
+		}
+
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MLEqCompDataParse.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,747 @@
+/*
+* 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 "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: 
+*    
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning(disable: 4786 4250 4503 4541)
+
+
+#include "MLEqCompDataParse.h"
+
+#include <akndef.hrh>
+
+#include <sstream>
+#include <fstream>
+#include <algorithm>
+#include <iostream> // !!! for debug output only
+
+extern string whiteSpace;
+
+
+// 
+// const data
+//
+
+const string KEqListParseRoot = "MasterLayout";
+
+const string KEqListParseComponent = "Component";
+const string KEqListParseComponentId = "compId";
+const string KEqListParseComponentLevel = "level";
+const string KEqListParseComponentName = "name";
+const string KEqListParseComponentPureSection = "pureSection";
+const string KEqListParseComponentType = "type";
+
+
+const string KEqCompDataParseRoot = "Layout";
+
+const string KEqCompDataParseRootAttributeMasterName = "MasterName";
+const string KEqCompDataParseRootAttributeLayoutName = "LayoutName";
+const string KEqCompDataParseRootAttributeVariantName = "variant_name";
+const string KEqCompDataParseRootAttributeResolutionHeight = "resolutionHeight";
+const string KEqCompDataParseRootAttributeResolutionWidth = "resolutionWidth";
+const string KEqCompDataParseRootAttributeCreatedOn = "createdOn";
+
+const string KEqCompDataParseNodeComponent = "Component";
+const string KEqCompDataParseNodeComponentAttributeName = "name";
+const string KEqCompDataParseNodeComponentAttributeId = "id";
+const string KEqCompDataParseNodeComponentAttributeType = "type";
+const string KEqCompDataParseNodeComponentAttributeDrawingOrder = "drawingorder";
+const string KEqCompDataParseNodeComponentAttributeMirror = "mirror";
+const string KEqCompDataParseNodeComponentAttributeMaxVariety = "maxVariety";
+
+const string KEqCompDataParseTextComponentTypeScreen= "0"; // "Screen";
+const string KEqCompDataParseTextComponentTypeContainer= "1"; // "Container";
+const string KEqCompDataParseTextComponentTypePane= "2"; // "Pane";
+const string KEqCompDataParseTextComponentTypeGraphic= "3"; // "Graphic";
+const string KEqCompDataParseTextComponentTypeText= "4"; // "Text";
+
+const string KEqCompDataParseTextComponentMirrorTrue= "true";
+
+const string KEqCompDataParseNodeOption = "option";
+const string KEqCompDataParseNodeParentInfo = "ParentInfo";
+const string KEqCompDataParseNodeLayoutInfo = "LayoutInfo";
+const string KEqCompDataParseNodeAttributeInfo = "AttributeInfo";
+const string KEqCompDataParseNodeAttrSets = "attrsets";
+
+const string KEqCompDataParseNodeParent = "parent";
+const string KEqCompDataParseNodeParentOption = "option";
+const string KEqCompDataParseNodeParentOptionAttributeVariety = "variety";
+const string KEqCompDataParseNodeParentInfoParentAttributeId = "id";
+const string KEqCompDataParseNodeParentInfoParentAttributeVariety = "variety";
+
+const string KEqCompDataParseNodeLayoutInfoParam = "Param";
+const string KEqCompDataParseNodeLayoutInfoParamAttributeName = "name";
+
+const string KEqCompDataParseNodeValue = "Value";
+const string KEqCompDataParseNodeVarietyIndex = "varietyIndex";
+const string KEqCompDataParseNodeVarietyIndexValue = "value";
+const string KEqCompDataParseNodeOptionSetNo = "optionSetNo";
+const string KEqCompDataParseNodeOptionSetNoValue = "value";
+const string KEqCompDataParseNodeCalc = "calc";
+const string KEqCompDataParseNodeFormulae = "Formulae";
+const string KEqCompDataParseNodeFormula = "Formula";
+const string KEqCompDataParseNodeFormulaFormulaStr = "formulaStr";
+const string KEqCompDataParseNodeFormulaZoomId = "zId";
+
+const string KEqCompDataParseNodeCalcAttributeValue = "value";
+const string KEqCompDataParseNodeCalcAttributeColNumber = "colNumber";
+const string KEqCompDataParseNodeCalcAttributeRowNumber = "rowNumber";
+const string KEqCompDataParseNodeCalcAttributeShowInTable = "showInTable";
+const string KEqCompDataParseNodeCalcAttributeShowInTableTrue = "true";
+const string KEqCompDataParseNodeCalcAttributeShowInTableFalse = "false";
+const string KEqCompDataParseNodeCalcAttributeZoom = "zoom";
+const string KEqCompDataParseNodeCalcAttributeZoomNormal = "normal";
+const string KEqCompDataParseNodeCalcAttributeZoomVerySmall = "-2 zoom";
+const string KEqCompDataParseNodeCalcAttributeZoomSmall = "-1 zoom";
+const string KEqCompDataParseNodeCalcAttributeZoomLarge = "+1 zoom";
+const string KEqCompDataParseNodeCalcAttributeZoomVeryLarge = "+2 zoom";
+
+const string KEqCompDataParseTextFontPrimary = "qfn_primary";
+const string KEqCompDataParseTextFontSecondary = "qfn_secondary";
+const string KEqCompDataParseTextFontTitle = "qfn_title";
+const string KEqCompDataParseTextFontPrimarySmall = "qfn_primary_small"; // is that the correct text?
+const string KEqCompDataParseTextFontDigital = "qfn_digital";
+
+const string KEqCompDataParseTextParamNameLeft = "Left";
+const string KEqCompDataParseTextParamShortNameLeft = "l";
+const string KEqCompDataParseTextParamNameRight = "Right";
+const string KEqCompDataParseTextParamShortNameRight = "r";
+const string KEqCompDataParseTextParamNameTop = "Top";
+const string KEqCompDataParseTextParamShortNameTop = "t";
+const string KEqCompDataParseTextParamNameBottom = "Bottom";
+const string KEqCompDataParseTextParamShortNameBottom = "b";
+const string KEqCompDataParseTextParamNameWidth = "Width";
+const string KEqCompDataParseTextParamShortNameWidth = "w";
+const string KEqCompDataParseTextParamNameHeight = "Height";
+const string KEqCompDataParseTextParamShortNameHeight = "h";
+const string KEqCompDataParseTextParamNameJustification = "Justification";
+const string KEqCompDataParseTextParamShortNameJustification = "j";
+const string KEqCompDataParseTextParamNameType = "Type";
+const string KEqCompDataParseTextParamShortNameType = "Type";
+
+// these have been changed to lower case, so that matching
+// can be performed independent of case
+const string KEqCompDataParseTextParamTypeCalcValueNone = "none";
+const string KEqCompDataParseTextParamTypeCalcValueLeft = "left";
+const string KEqCompDataParseTextParamTypeCalcValueCenter = "center";
+const string KEqCompDataParseTextParamTypeCalcValueRight = "right";
+const string KEqCompDataParseTextParamTypeCalcValueBidi = "bidi";
+
+const string KEqCompDataParseNodeAttributeInfoOption = "option";
+const string KEqCompDataParseNodeAttributeInfoOptionAttributeVariety = "variety";
+const string KEqCompDataParseNodeAttributeInfoAttributeSet = "attributeset";
+const string KEqCompDataParseNodeAttributeInfoAttributeSetAttributeName = "name";
+
+const string KEqParChildParseRoot = "ParChildRelation";
+const string KEqParChildParseComponent = "Component";
+const string KEqParChildParseComponentId = "id";
+const string KEqParChildParseComponentParent = "parent";
+const string KEqParChildParseComponentParentId = "parId";
+
+//
+// class TMLEqCompDataParseFormula
+//
+TMLEqCompDataParseFormula::TMLEqCompDataParseFormula()
+	: 
+	TMLEqCompDataFormula(),
+	iSaxFormulaString()
+	{
+
+	};
+
+MSaxLayoutEqHandler* TMLEqCompDataParseFormula::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if(aElement == KEqCompDataParseNodeFormula)
+		{
+		HandleSaxFormulaAttributes(aElement, aAttribs);
+		}
+	return this;
+	};
+
+void TMLEqCompDataParseFormula::HandleSaxEnd(const std::string& aElement)
+	{
+
+	};
+
+void TMLEqCompDataParseFormula::HandleSaxFormulaAttributes(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//	<Formula 
+//			formulaStr="3301_l-(pr199+pr197)" 
+//			lowerMargin="-1.0" 
+//			maxLimit="-1.0" 
+//			minLimit="-1.0" 
+//			prefNo="1" 
+//			sizer="-1" 
+//			upperMargin="-1.0" 
+//			zId="232" />
+
+	iFormulaString = aAttribs.getValue(KEqCompDataParseNodeFormulaFormulaStr);
+
+	string zoomIdStr = aAttribs.getValue(KEqCompDataParseNodeFormulaZoomId);
+	if(!zoomIdStr.empty())
+		iZoomId = CdlTkUtil::ParseInt(zoomIdStr);
+	else
+		iZoomId = -1; // @todo maybe could use dummy = 252?
+	}
+
+
+//
+// class TMLEqCompDataParseValuesOptionSet
+//
+TMLEqCompDataParseValuesOptionSet::TMLEqCompDataParseValuesOptionSet()
+	:
+	TMLEqCompDataValuesOptionSet(),
+	iSaxFormula(0),
+	iSaxFormulaNo(0),
+	iSaxOptionSetNo(-1)
+	{
+
+	};
+
+MSaxLayoutEqHandler* TMLEqCompDataParseValuesOptionSet::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//	<Value>
+//		<optionIndex value="0"/>
+//		<varietyIndex variety="0"/>
+//		<optionSetName orientation="3" value="Option0 (lists)"/>
+//		<optionSetNo value="0"/>
+//		<Formulae>
+//		...
+//		</Formulae>
+//		<Comment value=""/>
+//	</Value>
+
+	if (aElement == KEqCompDataParseNodeOptionSetNo)
+		{
+		HandleSaxOptionSetNo(aElement, aAttribs);
+		}
+	else if (aElement == KEqCompDataParseNodeFormulae)
+		{
+		return HandleSaxFormula(aElement, aAttribs);
+		}
+
+	return this;
+	};
+
+void TMLEqCompDataParseValuesOptionSet::HandleSaxEnd(const std::string& aElement)
+	{
+	if(aElement == KEqCompDataParseNodeFormulae)
+		{
+		push_back(*iSaxFormula);
+		delete iSaxFormula;
+		iSaxFormula = 0;
+		}
+	};
+
+void TMLEqCompDataParseValuesOptionSet::HandleSaxOptionSetNo(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+//	<optionSetNo value="1"/>
+
+	string optionSetNoStr = aAttribs.getValue(KEqCompDataParseNodeOptionSetNoValue);
+	iSaxOptionSetNo = CdlTkUtil::ParseInt(optionSetNoStr); // defaults to zero
+	}
+
+
+MSaxLayoutEqHandler* TMLEqCompDataParseValuesOptionSet::HandleSaxFormula(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+//	<Formula ... />
+
+	delete iSaxFormula;
+	iSaxFormula = 0;
+	iSaxFormula = new TMLEqCompDataParseFormula();
+	return iSaxFormula;
+	}
+
+
+
+//
+//  TMLEqCompDataParseValues
+//
+
+TMLEqCompDataParseValues::TMLEqCompDataParseValues(TMLEqCompDataLine* aLine)
+	: 
+	TMLEqCompDataValues(aLine), 
+	iSaxOptionSet(0)
+	{
+
+	}
+
+MSaxLayoutEqHandler* TMLEqCompDataParseValues::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+
+//	<Param name="Left">
+//		<Value>
+//			...
+//		</Value>
+//	</Param>
+
+	if (aElement == KEqCompDataParseNodeValue)
+		{
+		return HandleSaxOptionSet(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+void TMLEqCompDataParseValues::HandleSaxEnd(const std::string& aElement)
+	{
+	if (aElement == KEqCompDataParseNodeValue)
+		{
+		iOptionSets.insert(make_pair(iSaxOptionSet->OptionSetNo(), *iSaxOptionSet));
+		delete iSaxOptionSet;
+		iSaxOptionSet = 0;
+		}
+	}
+
+MSaxLayoutEqHandler* TMLEqCompDataParseValues::HandleSaxOptionSet(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+	delete iSaxOptionSet;
+	iSaxOptionSet = 0;
+	iSaxOptionSet = new TMLEqCompDataParseValuesOptionSet;
+	return iSaxOptionSet;
+	};
+
+
+void TMLEqCompDataParseValues::ConvertValueStr(std::string& aValueStr)
+	{
+	int valueInt = 0;
+	if(iName == KEqCompDataParseTextParamShortNameType)
+		{
+		if(aValueStr == KEqCompDataParseTextFontPrimary) 
+			valueInt = ELayoutCompilerFontCategoryPrimary;
+		else if(aValueStr == KEqCompDataParseTextFontSecondary)
+			valueInt = ELayoutCompilerFontCategorySecondary;
+		else if(aValueStr == KEqCompDataParseTextFontTitle)
+			valueInt = ELayoutCompilerFontCategoryTitle;
+		else if(aValueStr == KEqCompDataParseTextFontPrimarySmall) 
+			valueInt = ELayoutCompilerFontCategoryPrimarySmall;
+		else if(aValueStr == KEqCompDataParseTextFontDigital)
+			valueInt = ELayoutCompilerFontCategoryDigital;
+		else
+			valueInt = ELayoutCompilerFontCategoryUndefined;
+		aValueStr = CdlTkUtil::IntToString(valueInt);
+		}
+	else if(iName == KEqCompDataParseTextParamShortNameJustification)
+		{
+		// jusitication does not have consistent capitalization
+		string lowerValueStr = CdlTkUtil::ToLower(aValueStr);
+		if(lowerValueStr == KEqCompDataParseTextParamTypeCalcValueNone) 
+			valueInt = ELayoutAlignNone;
+		else if(lowerValueStr == KEqCompDataParseTextParamTypeCalcValueLeft) 
+			valueInt = ELayoutAlignLeft;
+		else if(lowerValueStr == KEqCompDataParseTextParamTypeCalcValueRight) 
+			valueInt = ELayoutAlignRight;
+		else if(lowerValueStr == KEqCompDataParseTextParamTypeCalcValueCenter) 
+			valueInt = ELayoutAlignCenter;
+		else if(lowerValueStr == KEqCompDataParseTextParamTypeCalcValueBidi) 
+			valueInt = ELayoutAlignBidi;
+		else 
+			valueInt = ELayoutAlignNone;
+		aValueStr = CdlTkUtil::IntToString(valueInt);
+		}
+	}
+
+int TMLEqCompDataParseValues::ConvertZoomStr(const std::string& aZoomStr)
+	{
+	int zoomInt = EAknUiZoomAutomatic;
+	string lowerZoomStr = CdlTkUtil::ToLower(aZoomStr);
+	if(lowerZoomStr.empty())
+		zoomInt = EAknUiZoomNormal;
+	else if(lowerZoomStr == KEqCompDataParseNodeCalcAttributeZoomVerySmall) 
+		zoomInt = EAknUiZoomVerySmall;
+	else if(lowerZoomStr == KEqCompDataParseNodeCalcAttributeZoomSmall) 
+		zoomInt = EAknUiZoomSmall;
+	else if(lowerZoomStr == KEqCompDataParseNodeCalcAttributeZoomLarge) 
+		zoomInt = EAknUiZoomLarge;
+	else if(lowerZoomStr == KEqCompDataParseNodeCalcAttributeZoomVeryLarge) 
+		zoomInt = EAknUiZoomVeryLarge;
+	return zoomInt;
+	}
+
+
+
+//
+//  TMLEqCompDataParseLine
+//
+
+TMLEqCompDataParseLine::TMLEqCompDataParseLine()
+	: 
+	TMLEqCompDataLine(), 
+	iSaxValues(0)
+//	iSaxParentInfo(0),
+//	iSaxAttributeInfo(0)
+	{
+	}
+
+MSaxLayoutEqHandler* TMLEqCompDataParseLine::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if(aElement == KEqCompDataParseNodeComponent)
+		{
+		HandleSaxAttributes(aAttribs);
+		}
+	else if(aElement == KEqCompDataParseNodeLayoutInfoParam)
+		{
+		//	<LayoutInfo>
+		//		<Param name="Left">
+		//		...
+		//	</LayoutInfo>
+		return HandleSaxParam(aElement, aAttribs);
+		}
+// @todo need to implement attribute parsing
+/*
+	else if(aElement == KEqCompDataParseNodeAttributeInfo)
+		{
+		return HandleSaxAttributeInfo(aElement, aAttribs);
+		}
+*/
+	return this;
+	}
+
+
+void TMLEqCompDataParseLine::HandleSaxAttributes(const TAttribs& aAttribs)
+	{
+// there are three different forms of component, stored in different files
+// but they all refer to the same components
+
+//	<Component 
+//		catRefId="3449" 
+//		componentCategory="0" 
+//		creationTime="1150805213430" 
+//		id="5129" 
+//		independent="false" 
+//		keepLocalCopy="true" 
+//		maxVariety="0" 
+//		type="4">
+
+	string idStr = aAttribs.getValue(KEqCompDataParseNodeComponentAttributeId);
+	iId = CdlTkUtil::ParseInt(idStr);
+
+	string name = aAttribs.getValue(KEqCompDataParseNodeComponentAttributeName);
+	if(!name.empty())
+		iName = name;
+
+	string typeStr = aAttribs.getValue(KEqCompDataParseNodeComponentAttributeType);
+	if(typeStr == KEqCompDataParseTextComponentTypeScreen)
+		{
+		iType = EScreenComponent;
+		}
+	else if(typeStr == KEqCompDataParseTextComponentTypeContainer)
+		{
+		iType = EContainerComponent;
+		}
+	else if(typeStr == KEqCompDataParseTextComponentTypePane)
+		{
+		iType = EPaneComponent;
+		}
+	else if(typeStr == KEqCompDataParseTextComponentTypeGraphic)
+		{
+		iType = EGraphicComponent;
+		}
+	else if(typeStr == KEqCompDataParseTextComponentTypeText)
+		{
+		iType = ETextComponent;
+		}
+	else
+		{
+		iType = EUnknownComponent;
+		}
+
+	// @todo don't know where drawing order is defined!
+//	string drawingOrderStr = aAttribs.getValue(KEqCompDataParseNodeComponentAttributeDrawingOrder);
+//	iDrawingOrder = CdlTkUtil::ParseInt(drawingOrderStr);
+
+		// @todo need to work out orientation from which 
+//	string mirroredStr = aAttribs.getValue(KEqCompDataParseNodeComponentAttributeMirror);
+//	iIsMirroredHorizontally = (mirroredStr == KEqCompDataParseTextComponentMirrorTrue); // will be false if empty, eg for a non-mirrored layout
+
+	}
+
+MSaxLayoutEqHandler* TMLEqCompDataParseLine::HandleSaxParam(const std::string& /*aElement*/, const TAttribs& aAttribs)
+	{
+	delete iSaxValues;
+	iSaxValues = 0;
+	iSaxValues = new TMLEqCompDataParseValues(this);
+
+	string nameStr = aAttribs.getValue(KEqCompDataParseNodeLayoutInfoParamAttributeName);
+	iSaxValues->iName = ShortParamName(nameStr);
+
+	return iSaxValues;
+	}
+
+void TMLEqCompDataParseLine::HandleSaxEnd(const std::string& aElement)
+	{
+	if(aElement == KEqCompDataParseNodeLayoutInfoParam)
+		{
+		insert(make_pair(iSaxValues->iName, *iSaxValues));
+		delete iSaxValues;
+		iSaxValues = 0;
+		}
+	}
+
+string TMLEqCompDataParseLine::ShortParamName(string& aName)
+	{
+	string shortName = aName;
+	if(aName == KEqCompDataParseTextParamNameLeft)
+		shortName = KEqCompDataParseTextParamShortNameLeft;
+	else if(aName == KEqCompDataParseTextParamNameRight)
+		shortName = KEqCompDataParseTextParamShortNameRight;
+	else if(aName == KEqCompDataParseTextParamNameTop)
+		shortName = KEqCompDataParseTextParamShortNameTop;
+	else if(aName == KEqCompDataParseTextParamNameBottom)
+		shortName = KEqCompDataParseTextParamShortNameBottom;
+	else if(aName == KEqCompDataParseTextParamNameWidth)
+		shortName = KEqCompDataParseTextParamShortNameWidth;
+	else if(aName == KEqCompDataParseTextParamNameHeight)
+		shortName = KEqCompDataParseTextParamShortNameHeight;
+	else if(aName == KEqCompDataParseTextParamNameJustification)
+		shortName = KEqCompDataParseTextParamShortNameJustification;
+	else if(aName == KEqCompDataParseTextParamNameType)
+		shortName = KEqCompDataParseTextParamShortNameType;
+	return shortName;
+	}
+
+
+//
+// class TMLEqListParseComponent
+//
+TMLEqListParseComponent::TMLEqListParseComponent()
+	{
+
+	}
+
+MSaxLayoutEqHandler* TMLEqListParseComponent::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+// <Component 
+//		compId="5129" 
+//		level="2" 
+//		name="list_form2_midp_pane_t1" 
+//		pureSection="false" 
+//		type="4">
+
+	if(aElement == KEqListParseComponent)
+		{
+		string idStr = aAttribs.getValue(KEqListParseComponentId);
+		iId = CdlTkUtil::ParseInt(idStr);
+
+		iName = aAttribs.getValue(KEqListParseComponentName);
+		}
+
+	return this;
+	}
+
+void TMLEqListParseComponent::HandleSaxEnd(const std::string& aElement)
+	{
+	// nothing to do
+	}
+
+
+//
+// class TMLEqParChildParseComponent
+//
+TMLEqParChildParseComponent::TMLEqParChildParseComponent()
+	{
+
+	}
+
+MSaxLayoutEqHandler* TMLEqParChildParseComponent::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//	<Component id="5198">
+//		<parent parId="529"/>
+//		<Option id="0" orientation="1" parOptionId="102"/>
+//		<Option id="0" orientation="2" parOptionId="102"/>
+//		<Option id="1" orientation="1" parOptionId="103"/>
+//		<Option id="1" orientation="2" parOptionId="103"/>
+//		<Option id="2" orientation="1" parOptionId="104"/>
+//		<Option id="2" orientation="2" parOptionId="104"/>
+//		<Option id="3" orientation="1" parOptionId="105"/>
+//		<Option id="3" orientation="2" parOptionId="105"/>
+//		<Document docParId="529" docSiblingLevel="1"/>
+//	</Component>
+
+	if(aElement == KEqParChildParseComponent)
+		{
+		string idStr = aAttribs.getValue(KEqParChildParseComponentId);
+		iId = CdlTkUtil::ParseInt(idStr);
+		}
+	else if(aElement == KEqParChildParseComponentParent)
+		{
+		HandleSaxParent(aElement, aAttribs);
+		}
+
+	return this;
+	}
+
+void TMLEqParChildParseComponent::HandleSaxEnd(const std::string& aElement)
+	{
+	// nothing to do
+	}
+
+void TMLEqParChildParseComponent::HandleSaxParent(const std::string& aElement, const TAttribs& aAttribs)
+	{
+//		<parent parId="529"/>
+
+		string parentIdStr = aAttribs.getValue(KEqParChildParseComponentParentId);
+		iParentId = CdlTkUtil::ParseInt(parentIdStr);
+
+		// @todo must implement a conversion for dummy components that have non-integer component ids.
+/*
+	if(iId == 0)
+		{
+		// this must be a dummy component, so have to fabricate a component id
+		if(iName == "text_primary")
+			iId = -1;
+		else if(iName == "text_secondary")
+			iId = -2;
+		else if(iName == "text_title")
+			iId = -3;
+		else if(iName == "text_primary_small")
+			iId = -4;
+		}
+*/
+	}
+
+
+//
+// class TMLEqCompDataParseLayout
+//
+
+MSaxLayoutEqHandler* TMLEqCompDataParseLayout::HandleSax(const std::string& aElement, const TAttribs& aAttribs)
+	{
+	if(aElement == KEqListParseRoot || aElement == KEqCompDataParseRoot || aElement == KEqParChildParseRoot)
+		{
+		iSaxLayoutType = aElement;
+		return this;
+		}
+	else if(aElement == KEqListParseComponent || aElement == KEqCompDataParseNodeComponent || aElement == KEqParChildParseComponent)
+		{
+		return HandleSaxComponent(aElement, aAttribs);
+		}
+	else
+		return this;
+	}
+
+void TMLEqCompDataParseLayout::HandleSaxEnd(const std::string& aElement)
+	{
+	}
+
+MSaxLayoutEqHandler* TMLEqCompDataParseLayout::HandleSaxComponent(const std::string& aElement, const TAttribs& aAttribs)
+	{
+
+	/// @todo not yet handling par child component!
+// <Component id="5198">
+
+	MSaxLayoutEqHandler* handler = NULL;
+	if(iSaxLayoutType == KEqListParseRoot)
+		{
+		TMLEqListParseComponent* line = new TMLEqListParseComponent();
+		line->HandleSax(aElement, aAttribs);
+		iListComponents.insert(make_pair(line->iId, line));
+		handler = line;
+		}
+	else if(iSaxLayoutType == KEqCompDataParseRoot)
+		{
+		TMLEqCompDataParseLine* line = new TMLEqCompDataParseLine();
+		line->HandleSax(aElement, aAttribs);
+		iComponents.insert(make_pair(line->iId, line));
+		handler = line;
+		}
+	else if(iSaxLayoutType == KEqParChildParseRoot)
+		{
+		TMLEqParChildParseComponent* line = new TMLEqParChildParseComponent();
+		line->HandleSax(aElement, aAttribs);
+		iParChildComponents.insert(make_pair(line->iId, line));
+		handler = line;
+		}
+	return handler;
+	}
+
+// this is the entry point into the parser
+auto_ptr<TMLEqCompDataParseLayout> TMLEqCompDataParseLayout::Parse(
+	const string& aListName, 
+	const string& aCompDataName, 
+	const string& aParChildName)
+	{
+	auto_ptr<TMLEqCompDataParseLayout> layout(new TMLEqCompDataParseLayout);
+	layout->iName = aCompDataName;
+
+	// SAX parsing method
+	TEqLayoutSaxParser saxParser(layout.get());
+
+	cout << "reading MLEqCompData(SAX) " << aListName << " + " << aCompDataName << " + " << aParChildName << endl;
+	saxParser.Parse(aListName);
+	saxParser.Parse(aCompDataName);
+	saxParser.Parse(aParChildName);
+
+	return layout;
+	}
+
+
+//
+// class TEqLayoutSaxParser
+//
+TEqLayoutSaxParser::TEqLayoutSaxParser(MSaxLayoutEqHandler* aHandler)
+	{ 
+	iStack.push(aHandler);
+	}
+
+void TEqLayoutSaxParser::Parse(const std::string& aFileName)
+	{
+	SAX::basic_InputSource<std::string> is(aFileName);
+	SAX::XMLReader<std::string> parser;
+	parser.setContentHandler(*this);
+	parser.setErrorHandler(*this);
+	parser.parse(is);
+	}
+
+void TEqLayoutSaxParser::startElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                              const std::string& /*qName*/, const SAX::basic_Attributes<std::string>& atts)
+    {
+	MSaxLayoutEqHandler* handler = iStack.top();
+	if (!handler)
+		throw GeneralErr("SAX: No element handler");
+	MSaxLayoutEqHandler* next = handler->HandleSax(localName, atts);
+	iStack.push(next);
+    }
+
+void TEqLayoutSaxParser::endElement(const std::string& /*namespaceURI*/, const std::string& localName,
+                            const std::string& /*qName*/)
+    {
+	iStack.pop();
+	MSaxLayoutEqHandler* handler = iStack.top();
+	if (handler)
+		handler->HandleSaxEnd(localName);
+    }
+
+
+void TEqLayoutSaxParser::warning(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TEqLayoutSaxParser::error(const TException& aException) 
+    {
+	cerr << aException.what();
+    }
+
+void TEqLayoutSaxParser::fatalError(const TException& aException)
+    {
+	cerr << aException.what();
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MakeLayConvTest.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "MakeLayConvTest.h"
+#include "LayoutCompilerErr.h"
+#include "LayoutParse.h"
+#include "Lay2Cdl.h"
+#include "CodeGenConsts.h"
+#include <fstream>
+#include <algorithm>
+#include <iostream>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<MakeLayoutConvTest> MakeLayoutConvTestArgsErr;
+
+
+
+int MakeLayoutConvTest::Process(const vector<string>& args)
+	{
+	if (args.size() != 4)
+		throw MakeLayoutConvTestArgsErr();
+
+	string cdlName = args[2];
+	CCdlTkCdlFileParser parser(cdlName);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+
+	string layoutName = args[3];
+	auto_ptr<TLayParseLayout> layoutParse = TLayParseLayout::Parse(layoutName);
+
+	MakeLayoutConvTest process(*iface, *layoutParse);
+	process.RunProcess();
+
+	return 0;
+	}
+
+void MakeLayoutConvTest::ShowHelp(ostream& stream)
+	{
+	stream << "MakeLayConvTest <cdlName> <layoutName>" << endl;
+	stream << "  Creates layout conversion test code." << endl;
+	}
+
+MakeLayoutConvTest::MakeLayoutConvTest(CCdlTkInterface& aInterface, TLayout& aLayout)
+: iInterface(aInterface), iLayout(aLayout)
+	{
+	}
+
+MakeLayoutConvTest::~MakeLayoutConvTest()
+	{
+	}
+
+void MakeLayoutConvTest::RunProcess()
+	{
+	InitFiles();
+
+	for (TLayout::iterator pTab = iLayout.begin(); pTab != iLayout.end(); ++pTab)
+		{
+		AddTableToTest(**pTab);
+		}
+
+	CompleteFiles();
+	WriteTestFiles();
+	}
+
+void MakeLayoutConvTest::AddTableToTest(TLayoutTable& aTable)
+	{
+	for (TLayoutTable::iterator pLine = aTable.begin(); pLine != aTable.end(); ++pLine)
+		{
+		TLayoutLine& line = **pLine;
+		AddLineToTest(line);
+		}
+
+	}
+
+void MakeLayoutConvTest::AddLineToTest(TLayoutLine& aLine)
+	{
+	string apiName = LayoutToCdl::LineApiName(aLine);
+	const CCdlTkFunctionApi* api = FindApi(apiName);
+	if (!api)
+		return;
+
+	AddTest(aLine, *api);
+	if (aLine["B"].size() > 1)
+		{
+		apiName = KFuncMultiline + apiName;
+		api = FindApi(apiName);
+		if (api)
+			{
+			AddTest(aLine, *api);
+			}
+		}
+	}
+
+void MakeLayoutConvTest::AddTest(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi)
+	{
+	AddTestToOldH(aLine, aApi);
+	AddTestToOldCpp(aLine, aApi);
+	AddTestFunc(aLine, aApi);
+	}
+
+const CCdlTkFunctionApi* MakeLayoutConvTest::FindApi(const string& aName)
+	{
+	return &iInterface.ApiList().Find(aName)->AsFunc();
+	}
+
+void MakeLayoutConvTest::WriteTestFiles()
+	{
+	WriteTestFile("OldLayout.h", iOldH);
+	WriteTestFile("OldLayout.cpp", iOldCpp);
+	WriteTestFile("TestLayout.cpp", iFuncs + iTests);
+	}
+
+void MakeLayoutConvTest::WriteTestFile(const string& aFileName, const string& iContent)
+	{
+	CCdlTkFileCleanup tempFile;
+	ofstream stream;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+	stream << iContent;
+	stream.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::ResolvePath(CdlTkUtil::OutputPath(), aFileName));
+	}
+
+void MakeLayoutConvTest::AddTestToOldH(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi)
+	{
+	string f = OldFuncSig(aLine, aApi) + ";\n";
+	CdlTkUtil::AppendString(iOldH, f);
+	}
+
+const string KOldFunc = "\
+$TYPE Old_$NAME$PARAMLIST\n\
+\t{\n\
+\treturn $LAGNAME$PARAMS;\n\
+\t}\n\n";
+
+void MakeLayoutConvTest::AddTestToOldCpp(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi)
+	{
+	string lagName = "AKN_LAYOUT_WINDOW_" + aApi.Name();
+	if (aApi.ReturnType() == KTypeTextLineLayout)
+		lagName = "AKN_LAYOUT_TEXT_" + aApi.Name();
+	else if (aApi.ReturnType() == KTypeMultiLineTextLayout)
+		lagName = "AKN_LAYOUT_MULTILINE_TEXT_" + aApi.Name().substr(KFuncMultiline.length());	// remove "Multiline_"
+
+	string params = aApi.ParamNameList();
+	if (!params.empty())
+		params = string("(") + params + ")";
+
+	CdlTkUtil::CReplaceSet rep;
+	rep.Add("$TYPE", aApi.ReturnType());
+	rep.Add("$NAME", aApi.Name());
+	rep.Add("$PARAMLIST", aApi.ParamsTypeAndNameList());
+	rep.Add("$LAGNAME", lagName);
+	rep.Add("$PARAMS", params);
+	CdlTkUtil::AppendString(iOldCpp, CdlTkUtil::MultiReplace(rep, KOldFunc));
+	}
+
+const string KTestFunc = "\
+void Test_$NAME(const AknLayout::CInstance& aInst)\n\
+\t{\n\
+$PARENT\
+$LOOPS_START\
+$INDENTCheckLayout(aInst.$NAME($PARAMS), Old_$NAME($PARAMS));\n\
+$LOOPS_END\
+\t}\n\n";
+
+const string KTestLoop = "$INDENTfor (" + KTypeInt + " $PARAM_NAME = 0; $PARAM_NAME < $MAX; $PARAM_NAME++)\n$INDENT\t{\n";
+
+void MakeLayoutConvTest::AddTestFunc(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi)
+	{
+	string testCall = string("\tTest_") + aApi.Name() + "(aInst);\n";
+	CdlTkUtil::AppendString(iTests, testCall);
+	string indent = "\t";
+
+	string loopStart;
+	string loopEnd;
+	const CCdlTkApiParams& params = aApi.Params();
+	for (CCdlTkApiParams::const_iterator pParam = params.begin(); pParam != params.end(); ++pParam)
+		{
+		if (pParam->Type() == KTypeInt)
+			{
+			string paramName = pParam->Name();
+			int max = 0;
+			for (TLayoutLine::iterator pVal = aLine.begin(); pVal != aLine.end(); ++pVal)
+				{
+				if (pVal->second.ParamName() == paramName)
+					{
+					max = pVal->second.size();
+					break;
+					}
+				}
+
+			CdlTkUtil::CReplaceSet rep;
+			rep.Add("$PARAM_NAME", paramName);
+			rep.Add("$MAX", CdlTkUtil::IntToString(max));
+			rep.Add("$INDENT", indent);
+			CdlTkUtil::AppendString(loopStart, CdlTkUtil::MultiReplace(rep, KTestLoop));
+			indent += "\t";
+			loopEnd = indent + "}\n" + loopEnd;
+			}
+		}
+
+	CdlTkUtil::CReplaceSet rep;
+	rep.Add("$NAME", aApi.Name());
+	rep.Add("$LOOPS_START", loopStart);
+	rep.Add("$PARAMS", aApi.ParamNameList());
+	rep.Add("$LOOPS_END", loopEnd);
+	rep.Add("$INDENT", indent);
+	rep.Add("$PARENT", aLine.iNeedsP ? "\tTRect aParentRect(0,0,176,208);\n" : "");
+	CdlTkUtil::AppendString(iFuncs, CdlTkUtil::MultiReplace(rep, KTestFunc));
+	}
+
+const string KOldFuncName = "Old_$NAME";
+const string KFuncSig = "$TYPE $NAME$PARAMS";
+
+string MakeLayoutConvTest::OldFuncSig(TLayoutLine& aLine, const CCdlTkFunctionApi& aApi)
+	{
+	string type = aApi.ReturnType();
+	string name = CdlTkUtil::Replace("$NAME", aApi.Name(), KOldFuncName);
+	string params = aApi.ParamsTypeAndNameList();
+
+	CdlTkUtil::CReplaceSet rep;
+	rep.Add("$TYPE", type);
+	rep.Add("$NAME", name);
+	rep.Add("$PARAMS", params);
+	return CdlTkUtil::MultiReplace(rep, KFuncSig);
+	}
+
+void MakeLayoutConvTest::InitFiles()
+	{
+	iOldH = "";
+
+	iOldCpp = "\
+#include <e32std.h>\n\
+#include <OldLayout.lag>\n\
+#include \"OldLayout.h\"\n\n";
+
+	iFuncs = "\
+#include \"LayTestUtils.h\"\n\
+#include \"OldLayout.h\"\n\n";
+
+	iTests = "\
+void RunTests(const AknLayout::CInstance& aInst)\n\
+\t{\n";
+
+	}
+
+void MakeLayoutConvTest::CompleteFiles()
+	{
+	iTests += "\t}\n";
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/MasterLayoutPack.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,332 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "MasterLayoutPack.h"
+#include "ZoomLevelNames.h"
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+
+#include <sstream>
+#include <iostream>
+#include <list>
+#include <algorithm>
+
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<MasterLayoutPackage> MasterLayoutPackageArgsErr;
+
+const string KMasterLayoutPackCdlFile = "MasterLayoutPack.cdl";
+
+typedef vector<string> PackageInfoLine;
+
+class MasterLayoutIndex
+	{
+public:
+	MasterLayoutIndex(list<PackageInfoLine> packageInfo, CZoomLevelNames& zoomLevelName, const string& fileName);
+	void BuildAndWrite();
+
+private:
+	enum InfoArgPositions
+		{
+		EPackNameArg = 0,
+		EWidthArg = 1,
+		EHeightArg = 2,
+		EVariantArg = 3,
+		EFirstContentArg = 4
+		};
+	
+	struct PkgSize
+		{
+		string iW;
+		string iH;
+		bool operator==(const PkgSize& aRhs)
+			{ return iW == aRhs.iW && iH == aRhs.iH; }
+		};
+
+private:
+	void BuildOptionsVectors();
+	void CreateTemplateInstance();
+	void SetSizes();
+	void SetVariants();
+	void SetZooms();
+	void SetContents();
+	void WriteInstance();
+	void Implement(const string& aApi, const string& aTarget, const string& aReplace);
+	void AddPkg(PackageInfoLine& aLine, const string& aZoom, string& aExtra, string& aImpl);
+	PackageInfoLine* FindLine(const PkgSize& aSize, const string& aVariant);
+
+private:
+	list<PackageInfoLine> iPackageInfo;
+	CZoomLevelNames& iZooms;
+	const string& iInstName;
+	vector<PkgSize> iSizes;
+	vector<string> iVariants;
+	auto_ptr<CCdlTkInterface> iIface;
+	auto_ptr<CCdlTkInstance> iInst;
+	};
+
+
+int MasterLayoutPackage::Process(vector<string>& args)
+	{
+	CZoomLevelNames zoomLevelNames;
+	zoomLevelNames.ProcessOptions(args);
+
+	if (args.size() != 2)
+		throw MasterLayoutPackageArgsErr();
+	
+	string& fileName = args[1];
+	ifstream in;
+	CdlTkUtil::OpenInput(in, fileName);
+
+	list<PackageInfoLine> packageInfo;
+	string line;
+	while (!in.eof())
+		{
+		getline(in, line);
+		PackageInfoLine words;
+		CdlTkUtil::Tokenize(line, back_insert_iterator<PackageInfoLine>(words));
+		if (words.size())
+			packageInfo.push_back(words);
+		}
+	in.close();
+
+	MasterLayoutIndex index(packageInfo, zoomLevelNames, fileName.substr(0,fileName.find_first_of('.')));
+	index.BuildAndWrite();
+
+	return 0;
+	}
+
+void MasterLayoutPackage::ShowHelp(ostream& stream)
+	{
+	stream << "MasterLayPkg [-z<zoomList>] <packageListFile>" << endl;
+	stream << "  Creates CDL package according to MasterLayoutPack.cdl containing" << endl;
+	stream << "  all of the packages described in <packageListFile>." << endl;
+	stream << "  The <packageListFile> should contain lines with the following contents:" << endl;
+	stream << "    <layout pack name> <width> <height> <layout variant> <content>*" << endl;
+	stream << "  If -z<zoomList> is specified, then instances for zoom factors" << endl;
+	stream << "  (in the form \"n,string\") appearing in the file <zoomList> will be generated, " << endl;
+	stream << "  by replacing the keyword $ZOOM in the package definitions." << endl;
+	}
+
+void MasterLayoutPackage_Process(
+	const string& aName, 
+	const string& aWidth, 
+	const string& aHeight, 
+	const string& aId, 
+	vector<string>::const_iterator aBegin, 
+	vector<string>::const_iterator aEnd, 
+	const string& aZoomName)
+	{
+	CCdlTkCdlFileParser parser(KDirDomainSysHeader+KMasterLayoutPackCdlFile);
+	auto_ptr<CCdlTkInterface> iface(parser.LoadAndParse(true));
+	CCdlTkInstance pkg(*iface);
+	pkg.TemplateAllImplementations();
+
+	string zoomName = CdlTkUtil::Replace("$ZOOM", aZoomName, aName);
+	string zoomIdName = "EAknUiZoom" + aZoomName;
+
+	pkg.SetName(zoomName);
+
+/*	Implement(pkg, "name", "\"\"", string("\"")+zoomName+"\"");
+	Implement(pkg, "size", "?width", aWidth);
+	Implement(pkg, "size", "?height", aHeight);
+	Implement(pkg, "id", "?value", aId);
+	Implement(pkg, "zoom", "?value", zoomIdName);
+*/
+	cout << zoomName << endl;
+
+	for (; aBegin != aEnd; ++aBegin)
+		{
+		string zoomContent = CdlTkUtil::Replace("$ZOOM", aZoomName, *aBegin);
+//		pkg.AddLocalContent(zoomContent);
+		cout << zoomContent << endl;
+		}
+
+	CCdlTkWriteInstance writer(pkg);
+	writer.Process();
+	}
+
+
+MasterLayoutIndex::MasterLayoutIndex(list<PackageInfoLine> packageInfo, CZoomLevelNames& zoomLevelName, const string& fileName)
+: iPackageInfo(packageInfo), iZooms(zoomLevelName), iInstName(fileName)
+	{
+	}
+
+void MasterLayoutIndex::BuildAndWrite()
+	{
+	BuildOptionsVectors();
+	CreateTemplateInstance();
+	SetSizes();
+	SetVariants();
+	SetZooms();
+	SetContents();
+	WriteInstance();
+	}
+
+void MasterLayoutIndex::BuildOptionsVectors()
+	{
+	for (list<PackageInfoLine>::iterator pLine=iPackageInfo.begin(); pLine!=iPackageInfo.end(); ++pLine)
+		{
+		if (pLine->size() < EFirstContentArg)
+			throw GeneralErr((*pLine)[EPackNameArg] + " package info has too few arguments");
+
+		PkgSize size;
+		size.iW = (*pLine)[EWidthArg];
+		size.iH = (*pLine)[EHeightArg];
+		if (find(iSizes.begin(), iSizes.end(), size) == iSizes.end())
+			iSizes.push_back(size);
+
+		string variant = (*pLine)[EVariantArg];
+		if (find(iVariants.begin(), iVariants.end(), variant) == iVariants.end())
+			iVariants.push_back(variant);
+		}
+	}
+
+void MasterLayoutIndex::CreateTemplateInstance()
+	{
+	CCdlTkCdlFileParser parser(KDirDomainSysHeader+KMasterLayoutPackCdlFile);
+	iIface = parser.LoadAndParse(true);
+	iInst = auto_ptr<CCdlTkInstance>(new CCdlTkInstance(*iIface));
+	iInst->TemplateAllImplementations();
+	iInst->SetName(iInstName);
+	// This master index should be the first in the DLL, so write it first.
+	cout << iInstName << endl;
+	}
+
+void MasterLayoutIndex::SetSizes()
+	{
+	string impl;
+	for (vector<PkgSize>::iterator pSize = iSizes.begin(); pSize != iSizes.end(); ++pSize)
+		{
+		CdlTkUtil::AppendString(impl, "\t{ ");
+		CdlTkUtil::AppendString(impl, pSize->iW);
+		CdlTkUtil::AppendString(impl, ", ");
+		CdlTkUtil::AppendString(impl, pSize->iW);
+		CdlTkUtil::AppendString(impl, " },\n");
+		}
+	Implement("sizes", "?array_contents", impl);
+	}
+
+void MasterLayoutIndex::SetVariants()
+	{
+	string impl;
+	for (vector<string>::iterator pVar = iVariants.begin(); pVar != iVariants.end(); ++pVar)
+		{
+		CdlTkUtil::AppendString(impl, "\t");
+		CdlTkUtil::AppendString(impl, *pVar);
+		CdlTkUtil::AppendString(impl, ",\n");
+		}
+	Implement("variants", "?array_contents", impl);
+	}
+
+void MasterLayoutIndex::SetZooms()
+	{
+	string impl;
+	for (CZoomLevelNames::iterator pZoom = iZooms.begin(); pZoom != iZooms.end(); ++pZoom)
+		{
+		CdlTkUtil::AppendString(impl, "\tEAknUiZoom");
+		CdlTkUtil::AppendString(impl, pZoom->second);
+		CdlTkUtil::AppendString(impl, ",\n");
+		}
+	Implement("zooms", "?array_contents", impl);
+	}
+
+void MasterLayoutIndex::SetContents()
+	{
+	string extra;
+	string impl;
+	for (vector<PkgSize>::iterator pSize = iSizes.begin(); pSize != iSizes.end(); ++pSize)
+		{
+		for (vector<string>::iterator pVar = iVariants.begin(); pVar != iVariants.end(); ++pVar)
+			{
+			PackageInfoLine* line = FindLine(*pSize, *pVar);
+			for (CZoomLevelNames::iterator pZoom = iZooms.begin(); pZoom != iZooms.end(); ++pZoom)
+				{
+				if (line == NULL)
+					CdlTkUtil::AppendString(impl, "\tNULL,\n");
+				else
+					AddPkg(*line, pZoom->second, extra, impl);
+				}
+			}
+		}
+	Implement("contents", "?array_contents", impl);
+	iInst->SetExtraCpp(extra);
+	}
+
+void MasterLayoutIndex::WriteInstance()
+	{
+	CCdlTkWriteInstance writer(*iInst);
+	writer.Process();
+	}
+
+void MasterLayoutIndex::Implement(const string& aApi, const string& aTarget, const string& aReplace)
+	{
+	CCdlTkImplementation* impl = iInst->Impl().Find(aApi);
+	if (!impl)
+		throw NotFoundErr(aApi + " in MasterLayoutPack.cdl");
+	CdlTkUtil::CReplaceSet implSet;
+	implSet.Add(aTarget, aReplace);
+	implSet.Add("	//TODO: Initialise this data.", "");
+	impl->SetDefinition(CdlTkUtil::MultiReplace(implSet, impl->Definition()));
+	}
+
+void MasterLayoutIndex::AddPkg(PackageInfoLine& aLine, const string& aZoom, string& aExtra, string& aImpl)
+	{
+	string impl = "&";
+	string extra;
+
+	string pkgName = CdlTkUtil::Replace("$ZOOM", aZoom, aLine[EPackNameArg]);
+	impl+=pkgName;
+
+	string refs;
+	for (int refPos = EFirstContentArg; refPos < aLine.size(); ++refPos)
+		{
+		string refName = CdlTkUtil::Replace("$ZOOM", aZoom, aLine[refPos]);
+		CdlTkUtil::AppendString(refs, CdlTkUtil::Replace("$NAME",refName,"\tLOCAL_CDL_REF($NAME),\n"));
+		}
+
+	CCdlTkDataTypeTranslations& translations = iIface->DataTypeTranslations();
+	string temp;
+	extra = translations.Find("TCdlArray<TCdlRef>", temp)->Definition();
+	CdlTkUtil::CReplaceSet defnSet;
+	defnSet.Add("aType", temp);
+	defnSet.Add("aName", pkgName);
+	defnSet.Add("?array_contents", refs);
+	extra = CdlTkUtil::MultiReplace(defnSet, extra);
+
+	CdlTkUtil::AppendString(aImpl, impl);
+	CdlTkUtil::AppendString(aExtra, extra);
+	}
+
+PackageInfoLine* MasterLayoutIndex::FindLine(const PkgSize& aSize, const string& aVariant)
+	{
+	for (list<PackageInfoLine>::iterator pLine=iPackageInfo.begin(); pLine!=iPackageInfo.end(); ++pLine)
+		{
+		if (aSize.iW == (*pLine)[EWidthArg] &&
+			aSize.iH == (*pLine)[EHeightArg] &&
+			aVariant == (*pLine)[EVariantArg])
+			return &*pLine;
+		}
+	return NULL;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/SaxErrorHandler.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       Defines the entry point for the console application
+*
+*/
+
+
+//
+// class SAXErrorHandler
+//
+
+#include "SaxErrorHandler.h"
+
+void SAXErrorHandler::warning(const SAX::SAXParseException& exception)
+{
+  std::cerr << "WARNING: " << exception.what() << std::endl;
+} // warning
+
+void SAXErrorHandler::error(const SAX::SAXParseException& exception)
+{
+  std::cerr << "ERROR  : " << exception.what() << std::endl;
+} // error
+
+void SAXErrorHandler::fatalError(const SAX::SAXParseException& exception)
+{
+  std::cerr << "FATAL  : " << exception.what() << std::endl;
+} // fatalError
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/Script.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+#include "Script.h"
+#include "LayoutCompilerErr.h"
+#include <iostream>
+#include <fstream>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<AknLayoutCompilerScript> AknLayoutCompilerScriptArgsErr;
+
+
+class ScriptErr : public LayoutCompilerErr
+	{
+public:
+	ScriptErr(const string& aLine, const string& aMsg) : iLine(aLine), iMsg(aMsg) {}
+private:
+	void Show(ostream& aStream) const;
+private:
+	string iLine;
+	string iMsg;
+	};
+
+void ScriptErr::Show(ostream& aStream) const
+	{
+	aStream << iLine << endl;
+	aStream << iMsg << endl;
+	}
+
+
+int AknLayoutCompilerScript::Process(const vector<string>& args)
+	{
+	if (args.size() != 2)
+		throw AknLayoutCompilerScriptArgsErr();
+
+	ifstream in;
+	CdlTkUtil::OpenInput(in, args[1].substr(1));
+
+	AknLayoutCompilerScript script(in);
+	script.Process();
+
+	in.close();
+
+	return 0;
+	}
+
+void AknLayoutCompilerScript::ShowHelp(ostream& /*stream*/)
+	{
+	}
+
+AknLayoutCompilerScript::AknLayoutCompilerScript(istream& aIn)
+: iIn(aIn)
+	{
+	}
+
+void AknLayoutCompilerScript::Process()
+	{
+//	while (!iIn.eof())
+//		{
+//		string line;
+//		getline(iIn, line);
+//		ProcessLine(line);
+//		}
+	}
+
+void AknLayoutCompilerScript::ProcessLine(string& aLine)
+	{
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(aLine);
+	if (aLine.empty())
+		return;
+
+	int paramStart = aLine.find_first_of('(');
+	int paramEnd = aLine.find_first_of(')');
+	if (paramStart == string::npos || paramEnd == string::npos)
+		throw ScriptErr(aLine, "Must be of form \"[result=] func(params)\"");
+
+	int eqPos = aLine.find_first_of('=');
+	string result;
+	if (eqPos > 0)
+		{
+		result = aLine.substr(0, eqPos-1);
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(result);
+		}
+
+	string func = aLine.substr(eqPos+1, paramStart-(eqPos+1));
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(func);
+	func = CdlTkUtil::ToLower(func);
+
+	paramStart++;
+	string params = aLine.substr(paramStart, paramEnd-paramStart);
+	vector<string> paramList;
+	int p = 0;
+	while (p != string::npos)
+		{
+		int n = params.find_first_of(',');
+		string param(params.substr(0, n));
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(param);
+		if (param.size())
+			paramList.push_back(param);
+		p = n;
+		if (p!=string::npos)
+			params = params.substr(p+1);
+		}
+
+	Process(func, paramList, result);
+	}
+
+void AknLayoutCompilerScript::Process(const string& aFunc, const vector<string>& aParamList, const string& aResult)
+	{
+	// use a map of name -> name, type and value
+	cout << aFunc << "[" << aParamList.size() << "|" << aResult << "]" << endl;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/UpdateLayoutApi.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+#include "UpdateLayoutApi.h"
+#include <cdlcompilertoolkit/cdltkprocess.h>
+#include "Lay2Cdl.h"
+#include "LayoutParse.h"
+#include "LayoutCompilerErr.h"
+#include <sstream>
+#include <iostream>
+
+using namespace std;
+
+typedef LayoutProcessArgsErr<UpdateLayoutApi> UpdateLayoutApiArgsErr;
+
+
+int UpdateLayoutApi::Process(const vector<string>& args)
+	{
+	if (args.size() != 6)
+		throw UpdateLayoutApiArgsErr();
+	
+	const string& cdlName = args[2];
+	const string& layoutName = args[3];
+	const string& legacyName = args[4];
+	const string& newName = args[5];
+
+	UpdateLayoutApi(cdlName, layoutName, legacyName, newName);
+
+	return 0;
+	}
+
+void UpdateLayoutApi::ShowHelp(ostream& stream)
+	{
+	stream << "UpdateLayoutApi <LayoutCdlApi> <CurrentLayout> <LegacyLayout> <NewLayout>" << endl;
+	}
+
+UpdateLayoutApi::UpdateLayoutApi(const std::string& aCdlName, const std::string& aLayoutName, const std::string& aLegacyName, const std::string& aNewName)
+: iCdlName(aCdlName), iLegacyName(aLegacyName), iInterface(0), iLayout(0), iLegacy(0), iNew(0), iInterfaceChanged(false)
+	{
+	LoadFiles(aLayoutName, aNewName);
+	MergeAndCheck();
+	ProcessNewApi();
+	WriteFiles();
+	Report();
+	}
+
+UpdateLayoutApi::~UpdateLayoutApi()
+	{
+	delete iInterface;
+	delete iLayout;
+	delete iLegacy;
+	delete iNew;
+	}
+
+void UpdateLayoutApi::LoadFiles(const std::string& aLayoutName, const std::string& aNewName)
+	{
+	CCdlTkCdlFileParser cdlParser(iCdlName);
+	auto_ptr<CCdlTkInterface> iface(cdlParser.LoadAndParse(false));
+	iInterface = iface.get();
+	iface.release();
+
+	auto_ptr<TLayParseLayout> layout(TLayParseLayout::Parse(aLayoutName));
+	iLayout = layout.get();
+	layout.release();
+
+	auto_ptr<TLayParseLayout> legacy(TLayParseLayout::Parse(iLegacyName));
+	iLegacy = legacy.get();
+	legacy.release();
+
+	auto_ptr<TLayParseLayout> newLay(TLayParseLayout::Parse(aNewName));
+	iNew = newLay.get();
+	newLay.release();
+	}
+
+void UpdateLayoutApi::MergeAndCheck()
+	{
+	TLayout combined(*iLayout);
+	combined.Merge(TLayout::KMergeModeMerge, *iLegacy);
+	auto_ptr<CCdlTkInterface> iface(LayoutToCdl::LayoutToInterface(combined));
+	InterfaceCheck check;
+	CCdlTkApiChecker process(*iInterface, *iface, check);
+	process.Process();
+	}
+
+void UpdateLayoutApi::ProcessNewApi()
+	{
+	auto_ptr<CCdlTkInterface> newIface(LayoutToCdl::LayoutToInterface(*iNew));
+	CCdlTkApiChecker process(*iInterface, *newIface, *this);
+	process.Process();
+	if (iInterfaceChanged)
+		{
+		CCdlTkInterface* curExt = iInterface->UltimateExtension();
+		if (!iExt)
+			iExt = new CCdlTkInterface();
+		curExt->SetExtension(iExt);
+		iExt->SetBase(curExt);
+		iExt->Header().SetVersion(CCdlTkInterfaceHeader::CVersion(curExt->Header().Version().Major(), curExt->Header().Version().Minor()+1));
+		}
+	}
+
+void UpdateLayoutApi::WriteFiles()
+	{
+	if (iInterfaceChanged)
+		{
+		}
+	if (iLegacyUpdated)
+		{
+		}
+	}
+
+void UpdateLayoutApi::Report()
+	{
+	if (!iReport.empty())
+		cout << iReport;
+	}
+
+void UpdateLayoutApi::StartCheck()
+	{
+	}
+
+void UpdateLayoutApi::CheckComplete()
+	{
+	}
+
+void UpdateLayoutApi::ApiInBoth(const CCdlTkApi& aApi)
+	{
+	}
+
+void UpdateLayoutApi::ApiNotInLeft(const CCdlTkApi& aApi)
+	{
+	// new API present - add it to the extension
+	iInterfaceChanged = true;
+	iExt->ApiList().push_back(aApi.Clone(*iExt));
+	}
+
+void UpdateLayoutApi::ApiNotInRight(const CCdlTkApi& aApi)
+	{
+	// old API not present - rename it in the API, add data to legacy.
+	iInterfaceChanged = true;
+	
+	string oldName = aApi.Name();
+	CCdlTkApi* api = iInterface->ApiList().Find(oldName);
+
+	CCdlTkInterfaceHeader& header = iInterface->UltimateExtension()->Header();
+	stringstream newName;
+	newName << oldName << "_V" << header.Version().Major() << "_" << header.Version().Minor();
+
+	api->SetName(newName.str());
+	AddDataToLegacy(oldName, newName.str());
+	}
+
+void UpdateLayoutApi::AddDataToLegacy(const std::string& /*aOldName*/, const std::string& /*aNewName*/)
+	{
+	iLegacyUpdated = true;
+	}
+
+
+void UpdateLayoutApi::InterfaceCheck::StartCheck()
+	{
+	}
+
+void UpdateLayoutApi::InterfaceCheck::CheckComplete()
+	{
+	}
+
+void UpdateLayoutApi::InterfaceCheck::ApiInBoth(const CCdlTkApi&)
+	{
+	}
+	
+void UpdateLayoutApi::InterfaceCheck::ApiNotInLeft(const CCdlTkApi&)
+	{
+	throw false;
+	}
+	
+	void UpdateLayoutApi::InterfaceCheck::ApiNotInRight(const CCdlTkApi&)
+	{
+	throw false;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/WriterBase.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*    
+*
+*/
+
+#include "WriterBase.h"
+
+// class TWriterBase
+
+TWriterBase::TWriterBase(const std::string& aName)
+: iName(aName)
+	{
+	}
+
+TWriterBase::~TWriterBase()
+	{
+	}
+
+
+// class TLayWriterBase
+
+TLayWriterBase::TLayWriterBase(TLayout& aLayout, const std::string& aName)
+: TWriterBase(aName), iLayout(aLayout)
+	{
+	}
+
+TLayWriterBase::~TLayWriterBase()
+	{
+	}
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aknlayoutcompiler/src/ZoomLevelNames.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+// disable "identifier was truncated to '255' characters in the browser information" warning
+#pragma warning (disable:4786)
+
+// disable "decorated name length exceeded, name was truncated" warning	
+#pragma warning (disable:4503)
+
+#include "ZoomLevelNames.h"
+#include "LayoutCompilerErr.h"
+#include "CodeGenConsts.h"
+
+#include <cdlcompilertoolkit/cdltkutil.h>
+
+#include <akndef.hrh>
+
+#include <fstream>
+#include <iostream>
+
+using namespace CdlCompilerToolkit;
+
+typedef LayoutProcessArgsErr<CZoomLevelNames> ZoomLevelNamesArgsErr;
+
+//
+// CZoomLevelNames
+//
+
+void CZoomLevelNames::ProcessOptions(vector<string>& aArgs)
+	{
+	bool zoomFileOk = false;
+	ifstream in;
+	string zoomFile;
+
+	for(vector<string>::iterator pArg = aArgs.begin(); pArg != aArgs.end(); ++pArg)
+		{
+		string& arg = *pArg;
+		if (arg.size() >= 2 && arg.substr(0,2) == "-z")
+			{
+			zoomFile = arg.substr(2);
+			try
+				{
+				CdlTkUtil::OpenInput(in, zoomFile);
+				zoomFileOk = true;
+				}
+			catch (const CdlTkFileOpenErr&)
+				{
+				}
+			aArgs.erase(pArg);
+			break;
+			}
+		}
+	if(zoomFileOk)
+		{
+		string line;
+		while (!in.eof())
+			{
+			getline(in, line);
+			int comma = line.find(",");
+			if(comma == string::npos)
+				{
+				cerr << "Zoom file incorrect format." << endl;
+				throw GeneralErr("Zoom file incorrect format");
+				}
+			int num = CdlTkUtil::ParseInt(line.substr(0, comma));
+			insert(make_pair(num, line.substr(comma+1)));
+			}
+		in.close();
+		}
+	else
+		{
+		// assume that normal zoom is the only one
+		insert(make_pair(EAknUiZoomNormal, KDefaultZoomInstanceName));
+		}
+	}
Binary file cdlcompiler/binary/CdlCompiler.EXE has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompiler/group/CdlCompiler.mmp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* 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 "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:
+*
+*/
+#include <platform_paths.hrh>
+
+target                  CdlCompiler.EXE
+targettype              EXE
+
+MW_LAYER_SYSTEMINCLUDE
+
+sourcepath              ../src 
+
+source CdlCompiler.cpp
+
+option MSVC /GX /W3
+
+#ifndef SBSV2
+  start CW32
+   win32_library /epoc32/release/cwtools/rel/CdlCompilerToolkit.lib
+  end
+
+  start VC32
+   win32_library /epoc32/release/tools/rel/CdlCompilerToolkit.lib
+  end
+#else  
+  START TOOLS
+    #if defined(CW32) 
+      win32_library /epoc32/release/cwtools/rel/CdlCompilerToolkit.lib
+    #elif defined(VC32)
+      win32_library /epoc32/release/tools/rel/CdlCompilerToolkit.lib
+    #endif
+  END
+#endif   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompiler/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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 "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:
+*
+*/
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+TOOLS CWTOOLS
+
+PRJ_EXPORTS
+
+../binary/CdlCompiler.EXE /epoc32/tools/CdlCompiler.exe 
+
+PRJ_MMPFILES
+
+#if defined(TOOLS) || defined(CWTOOLS)
+
+/*
+ * NOTICE! CdlCompiler is not compiled any more during usual build.
+ * It is just exported from ../binary directory.
+ * If you really want compile AknLayoutCompiler from sources you need to 
+ * uncomment below line, build this project and copy 
+ * /epoc32/tools/AknLayoutCompiler.exe to ../binary directory and 
+ * put the binary to version control.
+ */
+//CdlCompiler.mmp
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompiler/src/CdlCompiler.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,624 @@
+/*
+* 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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include <list>
+#include <sstream>
+#include <iomanip>
+#include <direct.h>
+#include <cdlcompilertoolkit/cdltkutil.h>
+#include <cdlcompilertoolkit/cdltkprocess.h>
+using namespace std;
+using namespace CdlCompilerToolkit;
+
+#ifndef _DEBUG
+#define EXCEPTION_HANDLING
+#endif
+
+
+typedef list<string> TArgsList;
+auto_ptr<CCdlTkInterfaceList> ParseList(const TArgsList& aFiles);
+
+//
+// MainArgsErr
+//
+
+class MainArgsErr : public CdlCompilerToolkitErr
+	{
+public:
+	MainArgsErr(const string& aExtraInfo = "");
+	void Show(ostream& aStream) const;
+private:
+	string iExtraInfo;
+	};
+
+MainArgsErr::MainArgsErr(const string& aExtraInfo)
+: iExtraInfo(aExtraInfo)
+	{
+	}
+
+void MainArgsErr::Show(ostream& stream) const
+	{
+	if (iExtraInfo.size())
+		{
+		stream << endl;
+		stream << iExtraInfo << endl;
+		}
+	stream << endl;
+	stream << "CdlCompiler <mode> [<options>] <mode specific parameters>" << endl;
+	stream << "  <mode> is:" << endl;
+	stream << "    \"client\" mode creates the API for a customisable component." << endl;
+	stream << "    \"instance\" mode creates customisation instance C++ files." << endl;
+	stream << "    \"package\" mode creates package instance C++ files." << endl;
+	stream << "    \"dll\" mode creates C++ and project files to collect together customisation instances in a DLL." << endl;
+	stream << "    \"compare\" compares two CDL interfaces." << endl;
+	stream << "  <options> are:" << endl;
+	stream << "    -p<output path>  path for the output files." << endl;
+	stream << "    -v               show CdlCompiler version." << endl;
+	stream << "    -h               show help information for a <mode>." << endl;
+	}
+
+
+//
+// CCompilerMode
+//
+
+class CCompilerMode 
+	{
+public:
+	virtual ~CCompilerMode();
+	virtual void ProcessOption(const std::string& aOpt);
+	virtual int Process(const TArgsList& aArgs) = 0;
+	virtual void ShowHelp(ostream& aStream) = 0;
+	};
+
+CCompilerMode::~CCompilerMode()
+	{
+	}
+
+void CCompilerMode::ProcessOption(const std::string& aOpt)
+	{
+	throw MainArgsErr(string("unrecognised option for this mode ") + aOpt);
+	}
+
+
+//
+// CClientMode
+//
+
+class CClientMode : public CCompilerMode
+	{
+public:
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+	};
+
+int CClientMode::Process(const TArgsList& aArgs)
+	{
+	auto_ptr<CCdlTkInterfaceList> cdls(ParseList(aArgs));
+	for (CCdlTkInterfaceList::iterator pCdl = cdls->begin(); pCdl != cdls->end(); ++pCdl)
+		{
+		CCdlTkWriteClientHeader processor(**pCdl);
+		processor.Process();
+		}
+	return 0;
+	}
+
+void CClientMode::ShowHelp(ostream& aStream)
+	{
+	aStream << "CdlCompiler client <options> [<CDL files>]" << endl;
+	aStream << "  client mode creates the API for a customisable component." << endl;
+	aStream << "  For each CDL file parameter, it creates C++ header files containing the API." << endl;
+	aStream << "  By default, these headers are placed in \\epoc32\\include." << endl;
+	}
+
+//
+// CInstanceMode
+//
+
+class CInstanceMode : public CCompilerMode
+	{
+public:
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+	};
+
+int CInstanceMode::Process(const TArgsList& aArgs)
+	{
+	TArgsList::const_iterator pArg = aArgs.begin();
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing CDL file name");
+
+	CCdlTkCdlFileParser parser(*pArg);
+	auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
+
+	++pArg;
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing instance name");
+	CCdlTkInstance inst(*cdl);
+	inst.SetName(*pArg);
+	inst.TemplateAllImplementations();
+
+	++pArg;
+	if (pArg != aArgs.end())
+		{
+		inst.SetId(CdlTkUtil::ParseInt(*pArg));
+		++pArg;
+		}
+
+	if (pArg != aArgs.end())
+		throw MainArgsErr("Too many parameters");
+
+	CCdlTkWriteInstance processor(inst);
+	processor.Process();
+	
+	return 0;
+	}
+
+void CInstanceMode::ShowHelp(ostream& aStream)
+	{
+	aStream << "CdlCompiler instance <options> <CDL file> <instance name> [<id>]" << endl;
+	aStream << "  instance mode creates C++ files containing a template customisation instance." << endl;
+	aStream << "  The customisation instance will implement the interface defined in <CDL file>." << endl;
+	aStream << "  It and its source files will be called <instance name>." << endl;
+	aStream << "  It will have an instance id of <id>, if specified. Otherwise," << endl;
+	aStream << "  the instance id will come from the host DLL." << endl;
+	}
+
+
+//
+// CPackageMode
+//
+
+class CPackageMode : public CCompilerMode
+	{
+public:
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+	};
+
+int CPackageMode::Process(const TArgsList& aArgs)
+	{
+	TArgsList::const_iterator pArg = aArgs.begin();
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing package CDL file name");
+
+	CCdlTkCdlFileParser parser(*pArg);
+	auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
+
+	++pArg;
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing package name");
+	CCdlTkPackage pckg(*cdl);
+	pckg.SetName(*pArg);
+	pckg.TemplateAllImplementations();
+
+	++pArg;
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing package instance id");
+
+	if (count_if(pArg->begin(), pArg->end(), CdlTkUtil::IsNumeric) == pArg->size())
+		{
+		pckg.SetId(CdlTkUtil::ParseInt(*pArg));
+		++pArg;
+		}
+
+	for (; pArg != aArgs.end(); ++pArg)
+		pckg.AddLocalContent(*pArg);
+
+	CCdlTkWriteInstance processor(pckg);
+	processor.Process();
+
+	return 0;
+	}
+
+void CPackageMode::ShowHelp(ostream& aStream)
+	{
+	aStream << "CdlCompiler package <options> <CDL file> <package name> [<id>] [<instance names>]" << endl;
+	aStream << "  package mode creates template package instance C++ files." << endl;
+	aStream << "  The package instance will implement the interface defined in <CDL file>." << endl;
+	aStream << "  It and its source files will be called <package name>." << endl;
+	aStream << "  It will have an instance id of <id> if <id> is a number." << endl;
+	aStream << "  The package contents will be references to the customisation instances <instance names>." << endl;
+	aStream << "  Note: the package contents will assume that all instances are in the same DLL." << endl;
+	}
+
+
+//
+// CDllMode
+//
+
+class CDllMode : public CCompilerMode
+	{
+public:
+	CDllMode();
+	void ProcessOption(const std::string& aOpt);
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+private:
+	CCdlTkDll::CLibraries iLibs;
+	string iExtraMmp;
+	int iVersion;
+	};
+
+CDllMode::CDllMode()
+: iVersion(1)
+	{
+	}
+
+void CDllMode::ProcessOption(const std::string& aOpt)
+	{
+	if (aOpt[1] == 'l')
+		{
+		iLibs.push_back(aOpt.substr(2));
+		}
+	else if (aOpt[1] == 's')
+		{
+		CdlTkUtil::AppendString(iExtraMmp, string("SOURCE "));
+		CdlTkUtil::AppendString(iExtraMmp, aOpt.substr(2));
+		CdlTkUtil::AppendString(iExtraMmp, "\n");
+		}
+	else if (aOpt[1] == 'e')
+		{
+		CdlTkUtil::AppendString(iExtraMmp, aOpt.substr(2));
+		CdlTkUtil::AppendString(iExtraMmp, "\n");
+		}
+	else if(aOpt[1] == 'n')
+		{
+		iVersion = CdlTkUtil::ParseInt(aOpt.substr(2));
+		if(iVersion < 1) iVersion = 1;
+		}
+	else
+		{
+		CCompilerMode::ProcessOption(aOpt);
+		}
+	}
+
+int CDllMode::Process(const TArgsList& aArgs)
+	{
+	TArgsList::const_iterator pArg = aArgs.begin();
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing DLL name");
+
+	CCdlTkDll dll;
+	dll.SetName(*pArg);
+	++pArg;
+
+	dll.SetVersion(iVersion);
+
+	if (pArg == aArgs.end())
+		throw MainArgsErr("Missing DLL UID");
+
+	dll.SetUid(CdlTkUtil::ParseInt(*pArg));
+	++pArg;
+
+	for (; pArg != aArgs.end(); ++pArg)
+		{
+		const string& inst = *pArg;
+		if (inst[0]!='@')
+			{
+			dll.AddInstance(*pArg);
+			}
+		else
+			{
+			// read instance list from a file
+			ifstream argFile;
+			CdlTkUtil::OpenInput(argFile, inst.substr(1));
+			string line;
+			while (!argFile.eof())
+				{
+				getline(argFile, line);
+				if (line.length())
+					dll.AddInstance(line);
+				}
+			argFile.close();
+			}
+		}
+
+	dll.Libraries().insert(dll.Libraries().end(), iLibs.begin(), iLibs.end());
+	dll.SetExtraMmp(dll.ExtraMmp() + iExtraMmp);
+
+	CCdlTkWriteDll processor(dll);
+	processor.Process();
+
+	return 0;
+	}
+
+void CDllMode::ShowHelp(ostream& aStream)
+	{
+	aStream << "CdlCompiler dll <options> <dll name> <uid> [<instance names>]" << endl;
+	aStream << "  dll mode creates C++ and project files to collect together customisation instances in a DLL." << endl;
+	aStream << "  The DLL and its source files will be called <dll name>." << endl;
+	aStream << "  It will have a UID of <uid>." << endl;
+	aStream << "  The DLL will contain customisation instances <instance names>." << endl;
+	aStream << "  If an instance name starts with @, this will be treated as the name of a file" << endl;
+	aStream << "  which contains a list of instance names, one per line." << endl;
+	aStream << "  Options:" << endl;
+	aStream << "    -l<libName> to add a library to the DLL." << endl;
+	aStream << "    -s<sourceFileName> to add a source file to the DLL." << endl;
+	aStream << "    -e<extraMmp> to add more statements to the DLL's MMP file." << endl;
+	aStream << "    -n<version> to set the DLL version number in format x, defaults to 1 when not specified or invalid." << endl;
+	aStream << "          Does not accept a minor version number." << endl;
+	}
+
+
+//
+// CCompareModeChecker
+//
+
+class CCompareModeChecker : public MCdlTkApiCheckObserver
+	{
+public:
+	CCompareModeChecker(const string& aLeft, const string& aRight);
+	virtual void StartCheck();
+	virtual void CheckComplete();
+	virtual void ApiInBoth(const CCdlTkApi& aApi);
+	virtual void ApiNotInLeft(const CCdlTkApi& aApi);
+	virtual void ApiNotInRight(const CCdlTkApi& aApi);
+
+private:
+	int iErrs;
+	string iLeft;
+	string iRight;
+	};
+
+CCompareModeChecker::CCompareModeChecker(const string& aLeft, const string& aRight)
+: iLeft(aLeft), iRight(aRight)
+	{
+	}
+
+void CCompareModeChecker::StartCheck()
+	{
+	iErrs = 0;
+	}
+
+void CCompareModeChecker::CheckComplete()
+	{
+	cout << "Check complete, " << iErrs << " differences found" << endl;
+	}
+
+void CCompareModeChecker::ApiInBoth(const CCdlTkApi& /*aApi*/)
+	{
+	}
+
+void CCompareModeChecker::ApiNotInLeft(const CCdlTkApi& aApi)
+	{
+	cout << iRight << ": " << aApi.Name() << aApi.ParamsTypeAndNameList() << " not found in " << iLeft << endl;
+	iErrs++;
+	}
+
+void CCompareModeChecker::ApiNotInRight(const CCdlTkApi& aApi)
+	{
+	cout << iLeft << ": " << aApi.Name() << aApi.ParamsTypeAndNameList() << " not found in " << iRight << endl;
+	iErrs++;
+	}
+
+
+//
+// CCompareMode
+//
+
+class CCompareMode : public CCompilerMode
+	{
+public:
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+	};
+
+int CCompareMode::Process(const TArgsList& aArgs)
+	{
+	auto_ptr<CCdlTkInterfaceList> cdls(ParseList(aArgs));
+	if (cdls->size() != 2)
+		throw MainArgsErr("Exactly 2 CDL files required");
+	CCompareModeChecker reporter(*aArgs.begin(), *++(aArgs.begin()));
+	CCdlTkApiChecker checker(*(*cdls)[0], *(*cdls)[1], reporter);
+	checker.Process();
+
+	return 0;
+	}
+
+void CCompareMode::ShowHelp(ostream& aStream)
+	{
+	aStream << "CdlCompiler compare <options> <left CDL file> <right CDL file>" << endl;
+	aStream << "  compare mode reports the difference between two CDL interfaces." << endl;
+	}
+
+
+//
+// CCompareMode
+//
+
+class CBigApiTestMode : public CCompilerMode
+	{
+public:
+	int Process(const TArgsList& aArgs);
+	void ShowHelp(ostream& aStream);
+	};
+
+string MakeApiName(int i)
+	{
+	return string("Api")+CdlTkUtil::IntToString(i);
+	}
+
+int CBigApiTestMode::Process(const TArgsList& aArgs)
+	{
+	string name = "BigApi";
+	int size = CdlTkUtil::ParseInt(*aArgs.begin());
+
+	// make a CDL interface
+	CCdlTkInterface iface;
+	iface.SetFileName(name+".cdl");
+	CCdlTkInterfaceHeader& header = iface.Header();
+	header.SetName(name);
+	header.SetUid(0x0fffffff);
+	CCdlTkApiList& apiList = iface.ApiList();
+	for (int ii=0; ii<size; ii++)
+		{
+		auto_ptr<CCdlTkFunctionApi> api(new CCdlTkFunctionApi(iface));
+		api->SetName(MakeApiName(ii));
+		api->SetReturnType("TInt");
+		apiList.push_back(api.get());
+		api.release();
+		}
+
+	// write the CDL file
+	CCdlTkWriteCdlFile cdlWriter(iface);
+	cdlWriter.Process();
+
+	// make an instance
+	CCdlTkInstance inst(iface);
+	inst.SetName(name+"Inst");
+	inst.TemplateAllImplementations();
+	CCdlTkImplementations& impls = inst.Impl();
+	for (CCdlTkImplementations::iterator pImpl = impls.begin(); pImpl != impls.end(); ++pImpl)
+		{
+		CCdlTkImplementation& imp = **pImpl;
+		string defn = imp.Definition();
+		defn = CdlTkUtil::Replace("//TODO: Implement this function.", "return 0;", defn);
+		imp.SetDefinition(defn);
+		}
+
+	// write the instance
+	CCdlTkWriteInstance instWriter(inst);
+	instWriter.Process();
+
+	return 0;
+	}
+
+void CBigApiTestMode::ShowHelp(ostream& /*aStream*/)
+	{
+	}
+
+
+//
+// static functions
+//
+
+bool ProcessOptions(TArgsList::iterator& aArgIter, const TArgsList::iterator& aEnd, CCompilerMode& aMode)
+	{
+	while (aArgIter != aEnd && (*aArgIter)[0] == '-')
+		{
+		string& arg = *aArgIter;
+		if (arg.size() < 2)
+			throw MainArgsErr("bad option \"-\"");
+		switch (arg[1])
+			{
+			case 'p': 
+				CdlTkUtil::SetOutputPath(arg.substr(2));
+				break;
+			case 'v': 
+				cout << "CdlCompiler version " << KCdlCompilerMajorVersion << "." << KCdlCompilerMinorVersion << endl;
+				return true;		// exit CdlCompiler
+			case 'h': 
+				aMode.ShowHelp(cerr);
+				return true;		// exit CdlCompiler
+			default: 
+				aMode.ProcessOption(arg);
+				break;
+			}
+		++aArgIter;
+		}
+	return false;	// continue execution of the CdlCompiler
+	}
+
+auto_ptr<CCdlTkInterfaceList> ParseList(const TArgsList& aFiles)
+	{
+	auto_ptr<CCdlTkInterfaceList> ifaceList(new CCdlTkInterfaceList);
+
+	for (TArgsList::const_iterator pFile = aFiles.begin(); pFile != aFiles.end(); ++pFile)
+		{
+		CCdlTkCdlFileParser parser(*pFile);
+		auto_ptr<CCdlTkInterface> cdl = parser.LoadAndParse(true);
+		ifaceList->push_back(cdl.get());
+		cdl.release();
+		}
+
+	return ifaceList;
+	}
+
+int DoMain(int argc, char* argv[])
+	{
+	CdlTkUtil::SetCommandLine(argc, argv);
+
+	if (argc < 2)
+		throw MainArgsErr("Missing mode");
+
+	TArgsList args;
+	copy(argv + 1, argv + argc, back_inserter(args));
+	TArgsList::iterator pArg = args.begin();
+
+	// process mode arg
+	auto_ptr<CCompilerMode> mode;
+	if (*pArg == "client")
+		{
+		mode = auto_ptr<CCompilerMode>(new CClientMode);
+		CdlTkUtil::SetOutputPath(CdlTkUtil::CurrentDrive() + "\\epoc32\\include\\");
+		}
+	else if (*pArg == "instance")
+		{
+		mode = auto_ptr<CCompilerMode>(new CInstanceMode);
+		}
+	else if (*pArg == "dll")
+		{
+		mode = auto_ptr<CCompilerMode>(new CDllMode);
+		}
+	else if (*pArg == "package")
+		{
+		mode = auto_ptr<CCompilerMode>(new CPackageMode);
+		}
+	else if (*pArg == "compare")
+		{
+		mode = auto_ptr<CCompilerMode>(new CCompareMode);
+		}
+	else if (*pArg == "BigApiTest")
+		{
+		mode = auto_ptr<CCompilerMode>(new CBigApiTestMode);
+		}
+	else
+		throw MainArgsErr(string("Unrecognised mode ") + *pArg);
+	++pArg;
+
+	// process options args
+	if (ProcessOptions(pArg, args.end(), *mode))
+		return 0;
+
+	// process mode args
+	return mode->Process(TArgsList(pArg, args.end()));
+	}
+
+int main(int argc, char* argv[])
+	{
+#ifdef EXCEPTION_HANDLING
+	try
+		{
+#endif
+		return DoMain(argc, argv);
+#ifdef EXCEPTION_HANDLING
+		}
+	catch (const CdlCompilerToolkitErr& aErr)
+		{
+		aErr.Show(cerr);
+		}
+
+	return 1;
+#endif
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompiler/test/Ex1.cdl	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,40 @@
+// The CDL header
+
+Name: Avkon LAF
+Version: 1.0
+UID: 0x1f123456
+
+
+%% C++
+
+// The C++ section
+
+struct TWindowLine
+	{
+	TInt16 t;
+	TInt16 l;
+	TInt16 r;
+	TInt16 b;
+	TInt16 w;
+	TInt16 h;
+	};
+
+
+%% Translation
+
+// The data type translation section. Format is:
+// <type> # <initialisation syntax> # <pointer reference syntax>
+
+TWindowLine # const TWindowLine aName = {0,0,0,0,0,0} # &aName
+
+
+%% API		// The API section
+
+// See C++ section for TWindowLine
+// it's a simple structure
+TWindowLine control_pane;			// example of data API
+
+TDesC introduction	;				// example of special type handling system
+
+TCdlArray<TInt> 
+	array_test;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompiler/test/Ex2.cdl	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,22 @@
+// ********** this is the original v1.0 interface ***********
+
+Name: extension test
+Version: 1.0
+UID: 0x1f123556
+
+
+%% API
+
+TInt v1_API;
+
+
+// ********** this is the start of the v1.1 extension ***********
+
+%% header
+
+Version: 1.1
+
+
+%% API
+
+TInt v2_API;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/bmarm/CDLU.DEF	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	KCdlMainExport @ 1 NONAME ; (null)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/bwins/CDLU.DEF	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?KCdlMainExport@@3USCdlMain@@B @ 1 NONAME ; struct SCdlMain const  KCdlMainExport
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/group/CdlCompilerToolkit.dep	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,107 @@
+# Microsoft Developer Studio Generated Dependency File, included by CdlCompilerToolkit.mak
+
+..\src\CdlTkClientHeader.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkDll.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkInstance.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkInterface.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkPackage.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkParser.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkProcess.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkSourceFileWriter.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkSyntaxCheck.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkUtil.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkWriteCdlFile.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkWriteDll.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
+
+..\src\CdlTkWriteInstance.cpp : \
+	"..\..\inc\cdlver.h"\
+	"..\inc\CdlTkInstance.h"\
+	"..\inc\CdlTkInterface.h"\
+	"..\inc\CdlTkPriv.h"\
+	"..\inc\CdlTkProcess.h"\
+	"..\inc\CdlTkUtil.h"\
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/group/CdlCompilerToolkit.dsp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,186 @@
+# Microsoft Developer Studio Project File - Name="CdlCompilerToolkit" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=CdlCompilerToolkit - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "CdlCompilerToolkit.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "CdlCompilerToolkit.mak" CFG="CdlCompilerToolkit - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "CdlCompilerToolkit - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "CdlCompilerToolkit - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "CdlCompilerToolkit"
+# PROP Scc_LocalPath ".."
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\REL"
+# PROP Intermediate_Dir "\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\REL"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "." /I "..\inc" /I "..\..\inc" /I "\epoc32\include" /I "\epoc32\include\CdlCompilerToolkit" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"\epoc32\release\tools\rel\CdlCompilerToolkit.lib"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PreLink_Cmds=if not exist \epoc32\tools\lib\. md \epoc32\tools\lib
+# End Special Build Tool
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\DEB"
+# PROP Intermediate_Dir "\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\DEB"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "..\inc" /I "..\..\inc" /I "\epoc32\include" /I "\epoc32\include\CdlCompilerToolkit" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"\epoc32\release\tools\deb\CdlCompilerToolkit.lib"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PreLink_Cmds=if not exist \epoc32\tools\lib\. md \epoc32\tools\lib
+# End Special Build Tool
+
+!ENDIF 
+
+# Begin Target
+
+# Name "CdlCompilerToolkit - Win32 Release"
+# Name "CdlCompilerToolkit - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\src\CdlTkClientHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkDll.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkInstance.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkInterface.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkInterfaceCheck.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkPackage.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkProcess.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkSourceFileWriter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkSyntaxCheck.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkUtil.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkWriteCdlFile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkWriteCommonDefs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkWriteDll.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\CdlTkWriteInstance.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\inc\CdlTkInstance.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\inc\CdlTkInterface.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\inc\CdlTkPriv.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\inc\CdlTkProcess.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\inc\CdlTkStdTrans.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\inc\CdlTkUtil.h
+# End Source File
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/group/CdlCompilerToolkit.mak	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,508 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on CdlCompilerToolkit.dsp
+!IF "$(CFG)" == ""
+CFG=CdlCompilerToolkit - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to CdlCompilerToolkit - Win32 Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "CdlCompilerToolkit - Win32 Release" && "$(CFG)" != "CdlCompilerToolkit - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "CdlCompilerToolkit.mak" CFG="CdlCompilerToolkit - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "CdlCompilerToolkit - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "CdlCompilerToolkit - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+OUTDIR=\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\REL
+INTDIR=\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\REL
+# Begin Custom Macros
+OutDir=\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\REL
+# End Custom Macros
+
+ALL : "..\..\..\epoc32\release\tools\rel\CdlCompilerToolkit.lib" "$(OUTDIR)\CdlCompilerToolkit.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\CdlTkClientHeader.obj"
+	-@erase "$(INTDIR)\CdlTkClientHeader.sbr"
+	-@erase "$(INTDIR)\CdlTkDll.obj"
+	-@erase "$(INTDIR)\CdlTkDll.sbr"
+	-@erase "$(INTDIR)\CdlTkInstance.obj"
+	-@erase "$(INTDIR)\CdlTkInstance.sbr"
+	-@erase "$(INTDIR)\CdlTkInterface.obj"
+	-@erase "$(INTDIR)\CdlTkInterface.sbr"
+	-@erase "$(INTDIR)\CdlTkInterfaceCheck.obj"
+	-@erase "$(INTDIR)\CdlTkInterfaceCheck.sbr"
+	-@erase "$(INTDIR)\CdlTkPackage.obj"
+	-@erase "$(INTDIR)\CdlTkPackage.sbr"
+	-@erase "$(INTDIR)\CdlTkParser.obj"
+	-@erase "$(INTDIR)\CdlTkParser.sbr"
+	-@erase "$(INTDIR)\CdlTkProcess.obj"
+	-@erase "$(INTDIR)\CdlTkProcess.sbr"
+	-@erase "$(INTDIR)\CdlTkScript.obj"
+	-@erase "$(INTDIR)\CdlTkScript.sbr"
+	-@erase "$(INTDIR)\CdlTkSourceFileWriter.obj"
+	-@erase "$(INTDIR)\CdlTkSourceFileWriter.sbr"
+	-@erase "$(INTDIR)\CdlTkSyntaxCheck.obj"
+	-@erase "$(INTDIR)\CdlTkSyntaxCheck.sbr"
+	-@erase "$(INTDIR)\CdlTkUtil.obj"
+	-@erase "$(INTDIR)\CdlTkUtil.sbr"
+	-@erase "$(INTDIR)\CdlTkWriteCdlFile.obj"
+	-@erase "$(INTDIR)\CdlTkWriteCdlFile.sbr"
+	-@erase "$(INTDIR)\CdlTkWriteDll.obj"
+	-@erase "$(INTDIR)\CdlTkWriteDll.sbr"
+	-@erase "$(INTDIR)\CdlTkWriteInstance.obj"
+	-@erase "$(INTDIR)\CdlTkWriteInstance.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(OUTDIR)\CdlCompilerToolkit.bsc"
+	-@erase "..\..\..\epoc32\release\tools\rel\CdlCompilerToolkit.lib"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /I "..\inc" /I "..\..\inc" /I "\epoc32\include" /I "\epoc32\include\CdlCompilerToolkit" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\CdlCompilerToolkit.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\CdlTkClientHeader.sbr" \
+	"$(INTDIR)\CdlTkDll.sbr" \
+	"$(INTDIR)\CdlTkInstance.sbr" \
+	"$(INTDIR)\CdlTkInterface.sbr" \
+	"$(INTDIR)\CdlTkInterfaceCheck.sbr" \
+	"$(INTDIR)\CdlTkPackage.sbr" \
+	"$(INTDIR)\CdlTkParser.sbr" \
+	"$(INTDIR)\CdlTkProcess.sbr" \
+	"$(INTDIR)\CdlTkSourceFileWriter.sbr" \
+	"$(INTDIR)\CdlTkSyntaxCheck.sbr" \
+	"$(INTDIR)\CdlTkUtil.sbr" \
+	"$(INTDIR)\CdlTkWriteCdlFile.sbr" \
+	"$(INTDIR)\CdlTkWriteDll.sbr" \
+	"$(INTDIR)\CdlTkWriteInstance.sbr" \
+	"$(INTDIR)\CdlTkScript.sbr"
+
+"$(OUTDIR)\CdlCompilerToolkit.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LIB32=link.exe -lib
+LIB32_FLAGS=/nologo /out:"\epoc32\release\tools\rel\CdlCompilerToolkit.lib" 
+LIB32_OBJS= \
+	"$(INTDIR)\CdlTkClientHeader.obj" \
+	"$(INTDIR)\CdlTkDll.obj" \
+	"$(INTDIR)\CdlTkInstance.obj" \
+	"$(INTDIR)\CdlTkInterface.obj" \
+	"$(INTDIR)\CdlTkInterfaceCheck.obj" \
+	"$(INTDIR)\CdlTkPackage.obj" \
+	"$(INTDIR)\CdlTkParser.obj" \
+	"$(INTDIR)\CdlTkProcess.obj" \
+	"$(INTDIR)\CdlTkSourceFileWriter.obj" \
+	"$(INTDIR)\CdlTkSyntaxCheck.obj" \
+	"$(INTDIR)\CdlTkUtil.obj" \
+	"$(INTDIR)\CdlTkWriteCdlFile.obj" \
+	"$(INTDIR)\CdlTkWriteDll.obj" \
+	"$(INTDIR)\CdlTkWriteInstance.obj" \
+	"$(INTDIR)\CdlTkScript.obj"
+
+"..\..\..\epoc32\release\tools\rel\CdlCompilerToolkit.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
+   if not exist \epoc32\tools\lib\. md \epoc32\tools\lib
+	 $(LIB32) @<<
+  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
+<<
+
+SOURCE="$(InputPath)"
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+OUTDIR=\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\DEB
+INTDIR=\epoc32\BUILD\S60\CDL\CDLCOMPILERTOOLKIT\GROUP\CDLCOMPILERTOOLKIT\TOOLS\DEB
+
+ALL : "..\..\..\epoc32\release\tools\deb\CdlCompilerToolkit.lib"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\CdlTkClientHeader.obj"
+	-@erase "$(INTDIR)\CdlTkDll.obj"
+	-@erase "$(INTDIR)\CdlTkInstance.obj"
+	-@erase "$(INTDIR)\CdlTkInterface.obj"
+	-@erase "$(INTDIR)\CdlTkInterfaceCheck.obj"
+	-@erase "$(INTDIR)\CdlTkPackage.obj"
+	-@erase "$(INTDIR)\CdlTkParser.obj"
+	-@erase "$(INTDIR)\CdlTkProcess.obj"
+	-@erase "$(INTDIR)\CdlTkScript.obj"
+	-@erase "$(INTDIR)\CdlTkSourceFileWriter.obj"
+	-@erase "$(INTDIR)\CdlTkSyntaxCheck.obj"
+	-@erase "$(INTDIR)\CdlTkUtil.obj"
+	-@erase "$(INTDIR)\CdlTkWriteCdlFile.obj"
+	-@erase "$(INTDIR)\CdlTkWriteDll.obj"
+	-@erase "$(INTDIR)\CdlTkWriteInstance.obj"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "..\..\..\epoc32\release\tools\deb\CdlCompilerToolkit.lib"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /ZI /Od /I "." /I "..\inc" /I "..\..\inc" /I "\epoc32\include" /I "\epoc32\include\CdlCompilerToolkit" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\CdlCompilerToolkit.bsc" 
+BSC32_SBRS= \
+	
+LIB32=link.exe -lib
+LIB32_FLAGS=/nologo /out:"\epoc32\release\tools\deb\CdlCompilerToolkit.lib" 
+LIB32_OBJS= \
+	"$(INTDIR)\CdlTkClientHeader.obj" \
+	"$(INTDIR)\CdlTkDll.obj" \
+	"$(INTDIR)\CdlTkInstance.obj" \
+	"$(INTDIR)\CdlTkInterface.obj" \
+	"$(INTDIR)\CdlTkInterfaceCheck.obj" \
+	"$(INTDIR)\CdlTkPackage.obj" \
+	"$(INTDIR)\CdlTkParser.obj" \
+	"$(INTDIR)\CdlTkProcess.obj" \
+	"$(INTDIR)\CdlTkSourceFileWriter.obj" \
+	"$(INTDIR)\CdlTkSyntaxCheck.obj" \
+	"$(INTDIR)\CdlTkUtil.obj" \
+	"$(INTDIR)\CdlTkWriteCdlFile.obj" \
+	"$(INTDIR)\CdlTkWriteDll.obj" \
+	"$(INTDIR)\CdlTkWriteInstance.obj" \
+	"$(INTDIR)\CdlTkScript.obj"
+
+"..\..\..\epoc32\release\tools\deb\CdlCompilerToolkit.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS)
+   if not exist \epoc32\tools\lib\. md \epoc32\tools\lib
+	 $(LIB32) @<<
+  $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS)
+<<
+
+SOURCE="$(InputPath)"
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("CdlCompilerToolkit.dep")
+!INCLUDE "CdlCompilerToolkit.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "CdlCompilerToolkit.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "CdlCompilerToolkit - Win32 Release" || "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+SOURCE=..\src\CdlTkClientHeader.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkClientHeader.obj"	"$(INTDIR)\CdlTkClientHeader.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkClientHeader.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkDll.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkDll.obj"	"$(INTDIR)\CdlTkDll.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkDll.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkInstance.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkInstance.obj"	"$(INTDIR)\CdlTkInstance.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkInstance.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkInterface.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkInterface.obj"	"$(INTDIR)\CdlTkInterface.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkInterface.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkInterfaceCheck.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkInterfaceCheck.obj"	"$(INTDIR)\CdlTkInterfaceCheck.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkInterfaceCheck.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkPackage.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkPackage.obj"	"$(INTDIR)\CdlTkPackage.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkPackage.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkParser.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkParser.obj"	"$(INTDIR)\CdlTkParser.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkParser.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkProcess.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkProcess.obj"	"$(INTDIR)\CdlTkProcess.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkProcess.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=.\CdlTkScript.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkScript.obj"	"$(INTDIR)\CdlTkScript.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkScript.obj" : $(SOURCE) "$(INTDIR)"
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkSourceFileWriter.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkSourceFileWriter.obj"	"$(INTDIR)\CdlTkSourceFileWriter.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkSourceFileWriter.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkSyntaxCheck.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkSyntaxCheck.obj"	"$(INTDIR)\CdlTkSyntaxCheck.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkSyntaxCheck.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkUtil.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkUtil.obj"	"$(INTDIR)\CdlTkUtil.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkUtil.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkWriteCdlFile.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkWriteCdlFile.obj"	"$(INTDIR)\CdlTkWriteCdlFile.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkWriteCdlFile.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkWriteDll.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkWriteDll.obj"	"$(INTDIR)\CdlTkWriteDll.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkWriteDll.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+SOURCE=..\src\CdlTkWriteInstance.cpp
+
+!IF  "$(CFG)" == "CdlCompilerToolkit - Win32 Release"
+
+
+"$(INTDIR)\CdlTkWriteInstance.obj"	"$(INTDIR)\CdlTkWriteInstance.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF  "$(CFG)" == "CdlCompilerToolkit - Win32 Debug"
+
+
+"$(INTDIR)\CdlTkWriteInstance.obj" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF 
+
+
+!ENDIF 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/group/CdlCompilerToolkit.mmp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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 "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:
+*
+*/
+#include <platform_paths.hrh>
+
+target                  CdlCompilerToolkit.lib
+targettype              LIB
+
+USERINCLUDE			../inc
+MW_LAYER_SYSTEMINCLUDE
+
+option MSVC /GX /W3
+
+sourcepath              ../src 
+
+source CdlTkClientHeader.cpp
+source CdlTkDll.cpp
+source CdlTkInstance.cpp
+source CdlTkInterface.cpp
+source CdlTkInterfaceCheck.cpp
+source CdlTkPackage.cpp
+source CdlTkParser.cpp
+source CdlTkProcess.cpp
+source CdlTkSourceFileWriter.cpp
+source CdlTkSyntaxCheck.cpp
+source CdlTkUtil.cpp
+source CdlTkWriteCdlFile.cpp
+source CdlTkWriteCommonDefs.cpp
+source CdlTkWriteDll.cpp
+source CdlTkWriteInstance.cpp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* 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 "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:
+*
+*/
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+TOOLS CWTOOLS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+#if defined(TOOLS) || defined(CWTOOLS)
+CdlCompilerToolkit.mmp
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/inc/CdlTkPriv.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef CDLTKPRIV_H
+#define CDLTKPRIV_H
+
+#include "CdlCompilerToolkit/CdlTkUtil.h"
+
+namespace CdlCompilerToolkit {
+
+const std::string KWhiteSpace(" \t\r\n");
+const std::string KSpace(" ");
+const std::string KEmptyString("");
+const std::string KSectionBoundary("%%");
+const std::string KCommentStart("//");
+const std::string KCrlf("\r\n");
+const std::string KCpp("0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
+const std::string KCommonHeader(".common.h");
+
+const std::string KType("aType");
+const std::string KName("aName");
+const std::string KEqualsSign("=");
+
+const int KTypeSize = KType.size();
+
+const std::string KPackageContentsApi("contents");
+
+const std::string KDllInstHeader("dllinstances.hrh");
+
+}	// end of namespace CdlCompilerToolkit
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/inc/CdlTkStdTrans.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* 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 "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:
+*
+*/
+// These are the standard data type translations supplied by the CDL compiler toolkit
+
+struct SStdTranslation
+	{
+	const char* iType;
+	const char* iInit;
+	const char* iRef;
+	};
+
+// these are the standard translations. First gets matched last.
+const SStdTranslation gStdTranslations[] =
+	{
+		{
+		"aType", 
+		"aType const aName = ?value", 
+		"&aName"
+		},
+		{
+		"TDesC",
+		"_LIT(aName,\"\")",
+		"LIT_AS_DESC_PTR(aName)"
+		},
+		{
+		"TCdlArray<aType>",
+		"CDL_ARRAY_START(aType, aName)\n\t{\n?array_contents\n\t}\nCDL_ARRAY_END(aType, aName)",
+		"&aName"
+		},
+		{
+		"TInt64", 
+		"SCdlInt64 const aName = { ?low_word, ?high_word }", 
+		"(const TInt64*)&aName"
+		},
+		{
+		"TVersion", 
+		"SCdlVersion const aName = { ?major, ?minor, ?build }", 
+		"(const TVersion*)&aName"
+		},
+		{
+		"TDateTime", 
+		"CDL_DATETIME(aName, ?year, ?month, ?day, ?hour, ?minute, ?second, ?microSecond)", 
+		"(const TDateTime*)&aName"
+		},
+		{
+		"TPoint", 
+		"SCdlPoint const aName = { ?x, ?y }", 
+		"(const TPoint*)&aName"
+		},
+		{
+		"TSize", 
+		"SCdlSize const aName = { ?width, ?height }", 
+		"(const TSize*)&aName"
+		},
+		{
+		"TRect", 
+		"SCdlRect const aName = { { ?left, ?top }, { ?right+1, ?bottom+1 } }", 
+		"(const TRect*)&aName"
+		},
+		{
+		"TRgb", 
+		"CDL_COLOR(aName, ?red, ?green, ?blue)", 
+		"(const TRgb*)&aName"
+		},
+	};
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkClientHeader.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+
+CCdlTkWriteClientHeader::CCdlTkWriteClientHeader(const CCdlTkInterface& aCdl)
+: iCdl(aCdl)
+	{
+	AssertInterfaceNotExtended(iCdl);
+	}
+
+CCdlTkWriteClientHeader::~CCdlTkWriteClientHeader()
+	{
+	}
+
+void CCdlTkWriteClientHeader::Process()
+	{
+	string baseName = CdlBaseNameAndPath(iCdl);
+
+	string commonHeaderName(baseName + KCommonHeader);
+	CCdlTkWriteCommonDefs::ExportCommonDefs(iCdl, commonHeaderName);
+
+	CCdlTkFileCleanup temp;
+	ofstream out;
+	CdlTkUtil::OpenTempOutput(out, temp);
+	string clientHeaderName(baseName + ".h");
+	ProcessApi(out, clientHeaderName);
+	out.close();
+	CdlTkUtil::ExportFile(temp, clientHeaderName);
+	}
+
+const string KClientApi = "$COMMENT $INDENT inline $TYPE $NAME $PARAMS $CONST\t\t{ $RETURN $CALL; }";
+const string KClientDataCall = "*($TYPE)($SCOPE::GetData($UID, EApiId_$NAME))";
+const string KClientFuncCall = "(*($TYPE)($SCOPE::GetFunction($UID, EApiId_$NAME)))($PARAMS)";
+
+void CCdlTkWriteClientHeader::WriteApi(const CCdlTkApi& aApi, ofstream& aStream, bool aCInstanceMember, const string& aIndent) const
+	{
+	CdlTkUtil::CReplaceSet callSet;
+	callSet.Add("$TYPE", aApi.PointerType());
+	callSet.Add("$SCOPE::", aCInstanceMember ? "" : "CdlEngine::");
+	callSet.Add("$UID, ", aCInstanceMember ? "" : "KCdlInterfaceUid, ");
+	callSet.Add("$NAME", aApi.Name());
+	callSet.Add("$PARAMS", aApi.IsFunc() ? aApi.AsFunc().ParamNameList() : "");
+	string call = CdlTkUtil::MultiReplace(callSet, aApi.IsFunc() ? KClientFuncCall : KClientDataCall);
+
+	string comment = CdlTkUtil::Replace("//", aIndent+"//", aApi.Comment());
+
+	CdlTkUtil::CReplaceSet apiSet;
+	apiSet.Add("$TYPE", ClientReturnType(aApi));
+	apiSet.Add("$NAME ", aApi.Name());
+	apiSet.Add("$PARAMS ", aApi.IsFunc() ? aApi.ParamsTypeAndNameList() : string("()"));
+	apiSet.Add("$CONST", aCInstanceMember ? " const" : "");
+	apiSet.Add("$RETURN ", (!aApi.IsFunc() || !aApi.IsVoidReturn()) ? "return " : "");
+	apiSet.Add("$CALL", call);
+	apiSet.Add("$INDENT ", aIndent);
+	apiSet.Add("$COMMENT ", comment);
+	string api = CdlTkUtil::MultiReplace(apiSet, KClientApi);
+
+	aStream << api << endl;
+	aStream << endl;
+	}
+
+string CCdlTkWriteClientHeader::ClientReturnType(const CCdlTkApi& aApi) const
+	{
+	string ret = aApi.ReturnType();
+	if (!aApi.IsFunc())
+		ret += " const&";
+	return ret;
+	}
+
+
+const string KBodyStart = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of  \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This file was generated by:\n\
+// $CMDLINE\n\
+// It contains the client API.\n\
+// It should not be modified manually.\n\
+\n\
+$ADDITIONAL\
+#ifndef $CDLGUARD\n\
+#define $CDLGUARD\n\
+\n\
+#include <cdlengine.h>\n\
+#include <$FILE.common.h>\n\
+\n\
+namespace $CDLNS\n\
+{\n\
+\n\
+class CInstance;\n\
+\n\
+// Standard interface functions \n\
+inline void LoadCustomisationL(const TCdlRef& aRef)                          { CdlEngine::LoadCustomisationL(aRef); }\n\
+inline void LoadCustomisationL(const TDesC& aLibName, TInt aInstId)          { TCdlRef ref = { aInstId, { KCdlInterfaceUidValue }, &aLibName }; LoadCustomisationL(ref); }\n\
+inline void RequireCustomisationL()                                          { CdlEngine::RequireCustomisationL(&KCdlInterface); }\n\
+inline TBool IsCustomisationStarted()                                        { return CdlEngine::IsCustomisationStarted(&KCdlInterface); }\n\
+inline const CInstance& CustomisationInstance()                              { return (const CInstance&)(CdlEngine::CustomisationInstance(KCdlInterfaceUid)); }\n\
+inline void SetCustomisationChangeObserverL(MCdlChangeObserver* aObserver)   { CdlEngine::SetCustomisationChangeObserverL(aObserver, KCdlInterfaceUid); }\n\
+\n\
+inline const TCdlRef& LastAccessedRef()                                      { return CdlEngine::LastAccessedRef(KCdlInterfaceUid); }\n\
+inline void FileNameRelativeToLastAccessedInstance(TFileName& aFileName)     { CdlEngine::FileNameRelativeToLastAccessedInstance(KCdlInterfaceUid, aFileName); }\n\
+\n\
+\n\
+// CDL API functions, as defined in $FILE\n\
+\n";
+
+const string KPragmaMinTypeInfo = "\
+#ifdef __VC32__\n\
+#pragma component(mintypeinfo, $ONOFF)\n\
+#endif\n\
+\n";
+
+const string KBodyMid = "\
+\n\
+\n\
+class CInstance : public CCdlInstance\n\
+\t{\n\
+public:\n\
+\tenum { ETypeId = KCdlInterfaceUidValue };\n\
+\n\
+\tinline static const CInstance& CustomisationInstance()                                                    { return (const CInstance&)(CdlEngine::CustomisationInstance(KCdlInterfaceUid)); }\n\
+\tinline static CInstance* NewL(const TCdlRef& aRef, const CCdlInstance* aSubLayer = NULL)                  { return (CInstance*) CCdlInstance::NewL(aRef, &KCdlInterface, aSubLayer); }\n\
+\tinline static CInstance* NewLC(const TCdlRef& aRef, const CCdlInstance* aSubLayer = NULL)                 { return (CInstance*) CCdlInstance::NewLC(aRef, &KCdlInterface, aSubLayer); }\n\
+\tinline static CInstance* NewL(const TDesC& aLibName, TInt aImplId, const CCdlInstance* aSubLayer = NULL)  { TCdlRef ref = { aImplId, { KCdlInterfaceUidValue }, &aLibName }; return NewL(ref, aSubLayer); }\n\
+\tinline static CInstance* NewLC(const TDesC& aLibName, TInt aImplId, const CCdlInstance* aSubLayer = NULL) { TCdlRef ref = { aImplId, { KCdlInterfaceUidValue }, &aLibName }; return NewLC(ref, aSubLayer); }\n\
+\n\
+\tinline const CInstance* SubLayer()                                                                        { return static_cast<const CInstance*>(CCdlInstance::SubLayer()); }\n\
+\n\
+// CDL API functions, as defined in $FILE\n\
+\n";
+
+const string KBodyEnd = "\
+private:\n\
+\tCInstance();\n\
+\t};\n\
+\n";
+
+const string KBodyEndNameSpace = "\
+} // end of namespace $CDLNS\n\
+#endif // $CDLGUARD\n";
+
+const int KMsvcClassMaxSize = 1000;
+const string KTypeInfoOn = "on";
+const string KTypeInfoOff = "off";
+
+void CCdlTkWriteClientHeader::ProcessApi(ofstream& aStream, const string& aFileName) const
+	{
+	CdlTkUtil::CReplaceSet replace;
+	replace.Add("$FILE", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iCdl.FileName())));
+	replace.Add("$CDLGUARD", HeaderGuardName(iCdl.FileName()));
+	replace.Add("$CDLNS", iCdl.NamespaceName());
+	replace.Add("$CMDLINE", CdlTkUtil::CommandLine());
+	replace.Add("$ADDITIONAL", iCdl.AdditionalComment());
+
+	bool tooMuchTypeInfo = iCdl.ApiList().size() > KMsvcClassMaxSize;
+
+	aStream << CdlTkUtil::MultiReplace(replace, KBodyStart);
+
+	CCdlTkApiList::const_iterator pApi;
+	for (pApi = iCdl.ApiList().begin(); pApi != iCdl.ApiList().end(); ++pApi)
+		WriteApi(**pApi, aStream, false, "");
+
+	if(tooMuchTypeInfo)
+		aStream << CdlTkUtil::Replace("$ONOFF", KTypeInfoOn, KPragmaMinTypeInfo);
+
+	aStream << CdlTkUtil::MultiReplace(replace, KBodyMid);
+
+	for (pApi = iCdl.ApiList().begin(); pApi != iCdl.ApiList().end(); ++pApi)
+		WriteApi(**pApi, aStream, true, "\t");
+
+	aStream << CdlTkUtil::MultiReplace(replace, KBodyEnd);
+
+	if(tooMuchTypeInfo)
+		aStream << CdlTkUtil::Replace("$ONOFF", KTypeInfoOff, KPragmaMinTypeInfo);
+
+	aStream << CdlTkUtil::MultiReplace(replace, KBodyEndNameSpace);
+	}
+
+
+}	// end of namespace CdlCompilerToolkit
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkDll.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,106 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkInstance.h"
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+CCdlTkDll::CCdlTkDll()
+: iUid(0), iVersion(1)
+	{
+	}
+
+CCdlTkDll::~CCdlTkDll()
+	{
+	}
+
+void CCdlTkDll::AddInstance(const CCdlTkInstance& aInstance)
+	{
+	AddInstance(aInstance.Name());
+	}
+
+void CCdlTkDll::AddInstance(const string& aInstanceName)
+	{
+	if (iUniqueInstances.find(aInstanceName) == iUniqueInstances.end())
+		{
+		iUniqueInstances.insert(aInstanceName);
+		iInstances.push_back(aInstanceName);
+		}
+	}
+
+const CCdlTkDll::CInstances& CCdlTkDll::Instances() const
+	{
+	return iInstances;
+	}
+
+void CCdlTkDll::SetName(const string& aName)
+	{
+	iName = aName;
+	}
+
+const string& CCdlTkDll::Name() const
+	{
+	return iName;
+	}
+
+void CCdlTkDll::SetUid(int aUid)
+	{
+	iUid = aUid;
+	}
+
+int CCdlTkDll::Uid() const
+	{
+	return iUid;
+	}
+
+void CCdlTkDll::SetVersion(int aVersion)
+	{
+	iVersion = aVersion;
+	}
+
+int CCdlTkDll::Version() const
+	{
+	return iVersion;
+	}
+
+void CCdlTkDll::AddLibrary(const string& aLibName)
+	{
+	iLibraries.push_back(aLibName);
+	}
+
+const CCdlTkDll::CLibraries& CCdlTkDll::Libraries() const
+	{
+	return iLibraries;
+	}
+
+CCdlTkDll::CLibraries& CCdlTkDll::Libraries()
+	{
+	return iLibraries;
+	}
+
+void CCdlTkDll::SetExtraMmp(const std::string& aExtraMmp)
+	{
+	iExtraMmp = aExtraMmp;
+	}
+
+const std::string& CCdlTkDll::ExtraMmp() const
+	{
+	return iExtraMmp;
+	}
+
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkInstance.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,273 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkInstance.h"
+#include "CdlTkPriv.h"
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+
+//
+// CCdlTkImplementation
+//
+
+CCdlTkImplementation::CCdlTkImplementation(const CCdlTkInstance& aInstance, const CCdlTkApi& aApi)
+: iInstance(aInstance), iApi(aApi)
+	{
+	SetNull();
+	}
+
+CCdlTkImplementation::~CCdlTkImplementation()
+	{
+	}
+
+string CCdlTkImplementation::Definition() const
+	{
+	return iDefn;
+	}
+
+void CCdlTkImplementation::SetDefinition(const string& aDefn)
+	{
+	iDefn = aDefn;
+	}
+
+const string KTemplateFuncDefn = "\
+$TYPE $NAME$PARAMS\n\
+\t{\n\
+\t//TODO: Implement this function.\n\
+\t}";
+
+void CCdlTkImplementation::SetTemplateDefinition()
+	{
+	if (iApi.IsFunc())
+		{
+		CdlTkUtil::CReplaceSet defnSet;
+		defnSet.Add("$TYPE", iApi.ReturnType());
+		defnSet.Add("$NAME", iApi.Name());
+		defnSet.Add("$PARAMS", iApi.ParamsTypeAndNameList());
+		iDefn = CdlTkUtil::MultiReplace(defnSet, KTemplateFuncDefn);
+		}
+	else
+		{
+		string typeVar;
+		iDefn = GetTranslation(iApi.ReturnType(), typeVar)->Definition();
+		CdlTkUtil::CReplaceSet defnSet;
+		defnSet.Add(KType, typeVar);
+		defnSet.Add(KName, iApi.Name());
+		iDefn = CdlTkUtil::MultiReplace(defnSet, iDefn);
+		CdlTkUtil::AppendString(iDefn, ";\t//TODO: Initialise this data.");
+		}
+	}
+
+const CCdlTkDataTypeTranslation* CCdlTkImplementation::GetTranslation(const string& aType, string& aTypeVar)
+	{
+	return iApi.Interface().DataTypeTranslations().Find(aType, aTypeVar);
+	}
+
+string CCdlTkImplementation::PointerReference() const
+	{
+	return iPtr;
+	}
+
+void CCdlTkImplementation::SetPointerReference(const string& aPtr)
+	{
+	iPtr = aPtr;
+	}
+
+void CCdlTkImplementation::SetTemplatePointerReference()
+	{
+	if (iApi.IsFunc())
+		{
+		iPtr = string("&") + iApi.Name();
+		}
+	else
+		{
+		string typeVar;
+		iPtr = GetTranslation(iApi.ReturnType(), typeVar)->PointerReference();
+		CdlTkUtil::CReplaceSet ptrSet;
+		ptrSet.Add(KType, typeVar);
+		ptrSet.Add(KName, iApi.Name());
+		iPtr = CdlTkUtil::MultiReplace(ptrSet, iPtr);
+		}
+	}
+
+const CCdlTkInstance& CCdlTkImplementation::Instance() const
+	{
+	return iInstance;
+	}
+
+const CCdlTkApi& CCdlTkImplementation::Api() const
+	{
+	return iApi;
+	}
+
+const string& CCdlTkImplementation::Name() const
+	{
+	return iApi.Name();
+	}
+
+void CCdlTkImplementation::SetTemplate()
+	{
+	SetTemplateDefinition();
+	SetTemplatePointerReference();
+	}
+
+void CCdlTkImplementation::SetNull()
+	{
+	SetDefinition("");
+	SetPointerReference("NULL");
+	}
+
+
+//
+// CCdlTkImplementations
+//
+
+CCdlTkImplementations::CCdlTkImplementations(const CCdlTkInstance& aInstance, const CCdlTkApiList& aApiList)
+	{
+	for (CCdlTkApiList::const_iterator pApi = aApiList.begin(); pApi != aApiList.end(); ++pApi)
+		{
+		iImpl.push_back(new CCdlTkImplementation(aInstance, **pApi));
+		}
+	}
+
+CCdlTkImplementations::~CCdlTkImplementations()
+	{
+	for (CImpl::iterator p = iImpl.begin(); p != iImpl.end(); ++p)
+		delete *p;
+	}
+
+CCdlTkImplementation* CCdlTkImplementations::Find(const string& aName) const
+	{
+	for (CImpl::const_iterator p = iImpl.begin(); p != iImpl.end(); ++p)
+		{
+		if ((*p)->Name() == aName)
+			return *p;
+		}
+	return 0;
+	}
+
+void CCdlTkImplementations::ClearAll()
+	{
+	for (CImpl::iterator pImp = iImpl.begin(); pImp != iImpl.end(); ++pImp)
+		{
+		(*pImp)->SetNull();
+		}
+	}
+
+void CCdlTkImplementations::TemplateAll()
+	{
+	for (CImpl::iterator pImp = iImpl.begin(); pImp != iImpl.end(); ++pImp)
+		{
+		(*pImp)->SetTemplate();
+		}
+	}
+
+
+//
+// CCdlTkInstance
+//
+
+#pragma warning (disable:4355)	// using "this" in initialisation list
+// note: "this" is not accessed during construction of iImpl
+CCdlTkInstance::CCdlTkInstance(const CCdlTkInterface& aInterface)
+: iInterface(aInterface), iImpl(*this, aInterface.ApiList()), iId(KCdlTkGetInstanceIdFromHostDll)
+	{
+	if (iInterface.Base() || iInterface.Extension())
+		throw CdlTkAssert("Can't create instance from extended interface - merge extensions first");
+	}
+#pragma warning (default:4355)	// using "this" in initialisation list
+
+CCdlTkInstance::~CCdlTkInstance()
+	{
+	}
+
+CCdlTkImplementations& CCdlTkInstance::Impl()
+	{
+	return iImpl;
+	}
+
+const CCdlTkImplementations& CCdlTkInstance::Impl() const
+	{
+	return iImpl;
+	}
+
+void CCdlTkInstance::SetName(const string& aName)
+	{
+	iName = aName;
+	}
+
+const string& CCdlTkInstance::Name() const
+	{
+	return iName;
+	}
+
+std::string CCdlTkInstance::DllInstanceName() const
+	{
+	return InstanceNameToDllInstanceName(iName);
+	}
+
+const string KDllInstanceName = "KDllInst_$INST";
+
+std::string CCdlTkInstance::InstanceNameToDllInstanceName(const std::string& aName)
+	{
+	return CdlTkUtil::Replace("$INST", CdlTkUtil::ToCpp(aName), KDllInstanceName);
+	}
+
+
+const CCdlTkInterface& CCdlTkInstance::Interface() const
+	{
+	return iInterface;
+	}
+
+void CCdlTkInstance::SetId()
+	{
+	iId = KCdlTkGetInstanceIdFromHostDll;
+	}
+
+void CCdlTkInstance::SetId(int aId)
+	{
+	iId = aId;
+	}
+
+int CCdlTkInstance::Id() const
+	{
+	return iId;
+	}
+
+const string& CCdlTkInstance::ExtraCpp() const
+	{
+	return iExtraCpp;
+	}
+
+void CCdlTkInstance::SetExtraCpp(const string& aExtra)
+	{
+	iExtraCpp = aExtra;
+	}
+
+void CCdlTkInstance::ClearAllImplementations()
+	{
+	iImpl.ClearAll();
+	}
+
+void CCdlTkInstance::TemplateAllImplementations()
+	{
+	iImpl.TemplateAll();
+	}
+
+}	// end of namespace CdlCompilerToolkit
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkInterface.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,972 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkInterface.h"
+#include "CdlTkPriv.h"
+#include "CdlTkStdTrans.h"
+#include <sstream>
+#include <CdlDef.h>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// TCdlTkFlag
+//
+
+struct TCdlTkFlag
+	{
+	const char* iName;
+	int iValue;
+	};
+
+const TCdlTkFlag gCdlTkFlags[] =
+	{
+		{ "KCdlFlagRomOnly", KCdlFlagRomOnlyValue }
+	};
+
+
+//
+// CCdlTkInterfaceHeader::CFlags
+//
+
+CCdlTkInterfaceHeader::CFlags::CFlags()
+: iFlags(0)
+	{
+	}
+
+void CCdlTkInterfaceHeader::CFlags::SetFlag(const string& aFlagName)
+	{
+	iFlags |= FlagVal(aFlagName);
+	}
+
+void CCdlTkInterfaceHeader::CFlags::ClearFlag(const string& aFlagName)
+	{
+	iFlags &= ~FlagVal(aFlagName);
+	}
+
+int CCdlTkInterfaceHeader::CFlags::FlagsAsInt() const
+	{
+	return iFlags;
+	}
+
+string CCdlTkInterfaceHeader::CFlags::FlagsAsString() const
+	{
+	string flags;
+	for (int bit=0; bit<Count(); bit++)
+		{
+		if (IsSet(bit))
+			{
+			if (!flags.empty())
+				CdlTkUtil::AppendString(flags, " | ");
+			CdlTkUtil::AppendString(flags, FlagName(bit));
+			}
+		}
+	if (flags.empty())
+		flags = "0";
+	return flags;
+	}
+
+int CCdlTkInterfaceHeader::CFlags::FlagVal(const string& aFlagName) const
+	{
+	for (int ii=0; ii<Count(); ii++)
+		{
+		const TCdlTkFlag& flag = gCdlTkFlags[ii];
+		if (aFlagName == flag.iName)
+			return flag.iValue;
+		}
+	throw CdlTkAssert(aFlagName + " : unknown flag");
+	return 0;
+	}
+
+string CCdlTkInterfaceHeader::CFlags::FlagName(int aFlagIndex) const
+	{
+	int flagVal = IndexToFlagVal(aFlagIndex);
+	for (int ii=0; ii<Count(); ii++)
+		{
+		const TCdlTkFlag& flag = gCdlTkFlags[ii];
+		if (flagVal == flag.iValue)
+			return flag.iName;
+		}
+	throw CdlTkAssert(CdlTkUtil::IntToString(aFlagIndex) + " : unknown flag index");
+	return "";
+	}
+
+int CCdlTkInterfaceHeader::CFlags::Count() const
+	{
+	return sizeof(gCdlTkFlags)/sizeof(*gCdlTkFlags);
+	}
+
+int CCdlTkInterfaceHeader::CFlags::IndexToFlagVal(int aIndex) const
+	{
+	return 1<<aIndex;
+	}
+
+bool CCdlTkInterfaceHeader::CFlags::IsSet(int aFlagIndex) const
+	{
+	return !!(iFlags & IndexToFlagVal(aFlagIndex));
+	}
+
+bool CCdlTkInterfaceHeader::CFlags::IsSet(const string& aFlagName) const
+	{
+	return !!(iFlags & FlagVal(aFlagName));
+	}
+
+CCdlTkInterfaceHeader::CFlags& CCdlTkInterfaceHeader::CFlags::operator|=(const CFlags& aOther)
+	{
+	iFlags |= aOther.iFlags;
+	return *this;
+	}
+
+
+//
+// CCdlTkInterfaceHeader::CVersion
+//
+
+CCdlTkInterfaceHeader::CVersion::CVersion()
+: iMajor(0), iMinor(0)
+	{
+	}
+
+CCdlTkInterfaceHeader::CVersion::CVersion(int aMajor, int aMinor)
+: iMajor(aMajor), iMinor(aMinor)
+	{
+	}
+
+bool CCdlTkInterfaceHeader::CVersion::operator<(const CVersion aOther) const
+	{
+	return  (iMajor < aOther.iMajor) ||
+			(iMajor == aOther.iMajor && iMinor < aOther.iMinor);
+	}
+
+bool CCdlTkInterfaceHeader::CVersion::operator==(const CVersion aOther) const
+	{
+	return iMajor == aOther.iMajor && iMinor == aOther.iMinor;
+	}
+
+int CCdlTkInterfaceHeader::CVersion::Major() const
+	{
+	return iMajor;
+	}
+
+void CCdlTkInterfaceHeader::CVersion::SetMajor(int aMajor)
+	{
+	iMajor = aMajor;
+	}
+
+int CCdlTkInterfaceHeader::CVersion::Minor() const
+	{
+	return iMinor;
+	}
+
+void CCdlTkInterfaceHeader::CVersion::SetMinor(int aMinor)
+	{
+	iMinor = aMinor;
+	}
+
+
+//
+// CCdlTkInterfaceHeader
+//
+
+CCdlTkInterfaceHeader::CCdlTkInterfaceHeader()
+: iName(""), iUid(0), iVer(0, 0)
+	{
+	}
+
+void CCdlTkInterfaceHeader::MergeExtensionHeader(const CCdlTkInterfaceHeader& aOther)
+	{
+	if (!aOther.iName.empty() && iName != aOther.iName)
+		throw CdlTkAssert("Can't change interface name in extension");
+	if (aOther.iUid && iUid != aOther.iUid)
+		throw CdlTkAssert("Can't change interface UID in extension");
+	if (!(iVer < aOther.iVer))
+		throw CdlTkAssert("Interface version must increase in extension");
+	iVer = aOther.iVer;
+	iFlags |= aOther.iFlags;
+	}
+
+string CCdlTkInterfaceHeader::Name() const
+	{
+	return iName;
+	}
+
+void CCdlTkInterfaceHeader::SetName(const string& aName)
+	{
+	iName = aName;
+	}
+
+int CCdlTkInterfaceHeader::Uid() const
+	{
+	return iUid;
+	}
+
+void CCdlTkInterfaceHeader::SetUid(int aUid)
+	{
+	iUid = aUid;
+	}
+
+void CCdlTkInterfaceHeader::SetVersion(const CVersion& aVer)
+	{
+	iVer = aVer;
+	}
+
+const CCdlTkInterfaceHeader::CVersion& CCdlTkInterfaceHeader::Version() const
+	{
+	return iVer;
+	}
+
+const CCdlTkInterfaceHeader::CFlags& CCdlTkInterfaceHeader::Flags() const
+	{
+	return iFlags;
+	}
+
+CCdlTkInterfaceHeader::CFlags& CCdlTkInterfaceHeader::Flags()
+	{
+	return iFlags;
+	}
+
+bool CCdlTkInterfaceHeader::operator==(const CCdlTkInterfaceHeader& aOther) const
+	{
+	return 
+		iName == aOther.iName &&
+		iUid == aOther.iUid &&
+		iVer == aOther.iVer;
+	}
+
+
+//
+// CCdlTkApiParam
+//
+
+CCdlTkApiParam::CCdlTkApiParam()
+	{
+	}
+
+CCdlTkApiParam::CCdlTkApiParam(const string& aType, const string& aName)
+: iType(aType), iName(aName)
+	{
+	}
+
+CCdlTkApiParam::CCdlTkApiParam(const string& aType, const string& aName, const std::string& aDefaultValue)
+: iType(aType), iName(aName), iDefaultValue(aDefaultValue)
+	{
+	}
+
+const string& CCdlTkApiParam::Type() const
+	{
+	return iType;
+	}
+
+void CCdlTkApiParam::SetType(const string& aType)
+	{
+	iType = aType;
+	}
+
+const string& CCdlTkApiParam::Name() const
+	{
+	return iName;
+	}
+
+void CCdlTkApiParam::SetName(const string& aName)
+	{
+	iName = aName;
+	}
+
+const string& CCdlTkApiParam::DefaultValue() const
+	{
+	return iDefaultValue;
+	}
+
+void CCdlTkApiParam::SetDefaultValue(const std::string& aDefaultValue)
+	{
+	iDefaultValue = aDefaultValue;
+	}
+
+
+bool CCdlTkApiParam::operator==(const CCdlTkApiParam& aOther) const
+	{
+	return Type() == aOther.Type() && Name() == aOther.Name() && DefaultValue() == aOther.DefaultValue();
+	}
+
+
+CCdlTkApiParams::iterator CCdlTkApiParams::FindByName(string aParamName)
+	{
+	iterator it;
+	for (it = begin(); it != end(); ++it)
+		{
+		if (it->Name() == aParamName)
+			break;
+		}
+	return it;
+	}
+
+
+//
+// CCdlTkApi
+//
+
+CCdlTkApi::CCdlTkApi(CCdlTkInterface& aInterface)
+: iInterface(aInterface)
+	{
+	}
+
+CCdlTkApi::~CCdlTkApi()
+	{
+	}
+
+const string& CCdlTkApi::ReturnType() const
+	{
+	return iReturnType;
+	}
+
+void CCdlTkApi::SetReturnType(const string& aType)
+	{
+	iReturnType = aType;
+	}
+
+bool CCdlTkApi::IsVoidReturn() const
+	{
+	return iReturnType == "void";
+	}
+
+const string& CCdlTkApi::Name() const
+	{
+	return iName;
+	}
+
+void CCdlTkApi::SetName(const string& aName)
+	{
+	iName = aName;
+	}
+
+int CCdlTkApi::SourceFileLineNum() const
+	{
+	return iSourceFileLineNum;
+	}
+
+void CCdlTkApi::SetSourceFileLineNum(int aLineNum)
+	{
+	iSourceFileLineNum = aLineNum;
+	}
+
+const string& CCdlTkApi::Comment() const
+	{
+	return iComment;
+	}
+
+void CCdlTkApi::SetComment(const string& aComment)
+	{
+	iComment = aComment;
+	}
+
+const CCdlTkInterface& CCdlTkApi::Interface() const
+	{
+	return iInterface;
+	}
+
+CCdlTkInterface& CCdlTkApi::Interface()
+	{
+	return iInterface;
+	}
+
+const CCdlTkFunctionApi& CCdlTkApi::AsFunc() const
+	{
+	if (!IsFunc())
+		throw CdlTkAssert("API is not a function");
+	return static_cast<const CCdlTkFunctionApi&>(*this);
+	}
+
+const CCdlTkDataApi& CCdlTkApi::AsData() const
+	{
+	if (IsFunc())
+		throw CdlTkAssert("API is not data");
+	return static_cast<const CCdlTkDataApi&>(*this);
+	}
+
+bool CCdlTkApi::operator!=(const CCdlTkApi& aOther) const
+	{
+	return !(*this == aOther);
+	}
+
+bool CCdlTkApi::operator==(const CCdlTkApi& aOther) const
+	{
+	return 
+		ReturnType() == aOther.ReturnType() &&
+		Name() == aOther.Name() &&
+		IsFunc() == aOther.IsFunc();
+	}
+
+void CCdlTkApi::operator=(const CCdlTkApi& aOther)
+	{
+	iReturnType = aOther.iReturnType;
+	iName = aOther.iName;
+	iSourceFileLineNum = aOther.iSourceFileLineNum;
+	}
+
+
+//
+// CCdlTkDataApi
+//
+
+CCdlTkDataApi::CCdlTkDataApi(CCdlTkInterface& aInterface)
+: CCdlTkApi(aInterface)
+	{
+	}
+
+CCdlTkDataApi::CCdlTkDataApi(CCdlTkInterface& aInterface, const CCdlTkDataApi& aCopy)
+: CCdlTkApi(aInterface)
+	{
+	CCdlTkApi::operator=(aCopy);
+	}
+
+bool CCdlTkDataApi::IsFunc() const
+	{
+	return false;
+	}
+
+string CCdlTkDataApi::PointerType() const
+	{
+	return ReturnType() + " const*";
+	}
+
+string CCdlTkDataApi::ParamsTypeAndNameList() const
+	{
+	return "";
+	}
+
+CCdlTkApi* CCdlTkDataApi::Clone(CCdlTkInterface& aInterface) const
+	{
+	return new CCdlTkDataApi(aInterface, *this);
+	}
+
+
+//
+// CCdlTkFunctionApi
+//
+
+CCdlTkFunctionApi::CCdlTkFunctionApi(CCdlTkInterface& aInterface)
+: CCdlTkApi(aInterface)
+	{
+	}
+
+CCdlTkFunctionApi::CCdlTkFunctionApi(CCdlTkInterface& aInterface, const CCdlTkFunctionApi& aCopy)
+: CCdlTkApi(aInterface)
+	{
+	CCdlTkApi::operator=(aCopy);
+	iParams = aCopy.iParams;
+	}
+
+bool CCdlTkFunctionApi::IsFunc() const
+	{
+	return true;
+	}
+
+string CCdlTkFunctionApi::PointerType() const
+	{
+	return ApiNameAsTypeName() + "*";
+	}
+
+string CCdlTkFunctionApi::ParamsTypeAndNameList() const
+	{
+	string ret = "(";
+	for (CCdlTkApiParams::const_iterator pParam = iParams.begin(); pParam != iParams.end(); ++pParam)
+		{
+		if (pParam != iParams.begin())
+			CdlTkUtil::AppendString(ret, string(",") + KSpace);
+		CdlTkUtil::AppendString(ret, pParam->Type() + KSpace + pParam->Name());
+		if(!(pParam->DefaultValue().empty()))
+			CdlTkUtil::AppendString(ret, KSpace + KEqualsSign + KSpace + pParam->DefaultValue());
+		}
+	ret += ")";
+	return ret;
+	}
+
+CCdlTkApiParams& CCdlTkFunctionApi::Params()
+	{
+	return iParams;
+	}
+
+const CCdlTkApiParams& CCdlTkFunctionApi::Params() const
+	{
+	return iParams;
+	}
+
+string CCdlTkFunctionApi::ApiNameAsTypeName() const
+	{
+	string name = "T";
+	name += Name();
+	name += "_sig";
+	return name;
+	}
+
+string CCdlTkFunctionApi::ParamNameList() const
+	{
+	string ret = "";
+	for (CCdlTkApiParams::const_iterator pParam = iParams.begin(); pParam != iParams.end(); ++pParam)
+		{
+		if (pParam != iParams.begin())
+			CdlTkUtil::AppendString(ret, ", ");
+		CdlTkUtil::AppendString(ret, pParam->Name());
+		}
+	return ret;
+	}
+
+string CCdlTkFunctionApi::ParamTypeList() const
+	{
+	string ret = "";
+	for (CCdlTkApiParams::const_iterator pParam = iParams.begin(); pParam != iParams.end(); ++pParam)
+		{
+		if (pParam != iParams.begin())
+			CdlTkUtil::AppendString(ret, ", ");
+		CdlTkUtil::AppendString(ret, pParam->Type());
+		}
+	return ret;
+	}
+
+bool CCdlTkFunctionApi::operator==(const CCdlTkApi& aOther) const
+	{
+	return 
+		CCdlTkApi::operator==(aOther) && 
+		Params() == aOther.AsFunc().Params();	// calling AsFunc() is safe because base-class == will fail if this is not a function API
+	}
+
+CCdlTkApi* CCdlTkFunctionApi::Clone(CCdlTkInterface& aInterface) const
+	{
+	return new CCdlTkFunctionApi(aInterface, *this);
+	}
+
+
+//
+// CCdlTkApiList
+//
+
+CCdlTkApiList::CCdlTkApiList()
+	{
+	}
+
+void CCdlTkApiList::Copy(const CCdlTkApiList& aOther, CCdlTkInterface& aInterface)
+	{
+	if (this == &aOther)
+		return;
+	DeleteApis();
+	clear();
+	reserve(aOther.size());
+	for (const_iterator pApi = aOther.begin(); pApi != aOther.end(); ++pApi)
+		push_back((*pApi)->Clone(aInterface));
+	}
+
+CCdlTkApiList::~CCdlTkApiList()
+	{
+	DeleteApis();
+	}
+
+void CCdlTkApiList::DeleteApis()
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		delete *it;
+	}
+
+void CCdlTkApiList::MergeExtendedApi(CCdlTkInterface& aInterface, const CCdlTkApiList& aOther)
+	{
+	for (const_iterator it = aOther.begin(); it != aOther.end(); ++it)
+		push_back((*it)->Clone(aInterface));
+	}
+
+CCdlTkApi* CCdlTkApiList::Find(const string& aName) const
+	{
+	for (const_iterator pApi = begin(); pApi != end(); ++pApi)
+		{
+		if ((*pApi)->Name() == aName)
+			return *pApi;
+		}
+	return 0;
+	}
+
+bool CCdlTkApiList::operator==(const CCdlTkApiList& aOther) const
+	{
+	if (size() != aOther.size())
+		return false;
+	const_iterator pOther = aOther.begin();
+	for (const_iterator pApi = begin(); pApi != end(); ++pApi)
+		{
+		if (**pApi != **pOther)
+			return false;
+		++pOther;
+		}
+	return true;
+	}
+
+bool CCdlTkApiList::IsSubsetOf(const CCdlTkApiList& aOther) const
+	{
+	for (const_iterator pApi = begin(); pApi != end(); ++pApi)
+		{
+		CCdlTkApi* api = aOther.Find((*pApi)->Name());
+		if (!api || **pApi != *api)
+			return false;
+		}
+	return true;
+	}
+
+
+//
+// CCdlTkCpp
+//
+
+CCdlTkCpp::CCdlTkCpp() 
+	{
+	}
+
+void CCdlTkCpp::MergeExtensionCpp(const CCdlTkCpp& aOther)
+	{
+	insert(end(), aOther.begin(), aOther.end());
+	}
+
+
+//
+// CCdlTkDataTypeTranslation
+//
+
+CCdlTkDataTypeTranslation::CCdlTkDataTypeTranslation()
+: iDefn(""), iPtrRef(""), iSource(EFromCdl)
+	{
+	SetType("");
+	}
+
+CCdlTkDataTypeTranslation::CCdlTkDataTypeTranslation(const string& aType)
+: iDefn(""), iPtrRef(""), iSource(EFromCdl)
+	{
+	SetType(aType);
+	}
+
+CCdlTkDataTypeTranslation::CCdlTkDataTypeTranslation(const string& aType, const string& aDefn, const string& aPtrRef, TTranslationSource aSource)
+: iDefn(aDefn), iPtrRef(aPtrRef), iSource(aSource)
+	{
+	SetType(aType);
+	}
+
+string CCdlTkDataTypeTranslation::Type() const
+	{
+	return iType;
+	}
+
+void CCdlTkDataTypeTranslation::SetType(const string& aType)
+	{
+	iType = aType;
+	iTypeSize = iType.size();
+	iTypeVarPos = iType.find(KType);
+	if (iTypeVarPos != string::npos)
+		{
+		iTypeSizeWithoutTypeVar = iTypeSize - KTypeSize;
+		iTextBeforeTypeVar = iType.substr(0, iTypeVarPos);
+		iTextAfterTypeVar = iType.substr(iTypeVarPos + KTypeSize);
+		iSizeAfterTypeVar = iTextAfterTypeVar.size();
+		}
+	}
+
+string CCdlTkDataTypeTranslation::Definition() const
+	{
+	return iDefn;
+	}
+
+void CCdlTkDataTypeTranslation::SetDefinition(const string& aDefn)
+	{
+	iDefn = aDefn;
+	}
+
+string CCdlTkDataTypeTranslation::PointerReference() const
+	{
+	return iPtrRef;
+	}
+
+void CCdlTkDataTypeTranslation::SetPointerReference(const string& aPtrRef)
+	{
+	iPtrRef = aPtrRef;
+	}
+
+CCdlTkDataTypeTranslation::TTranslationSource CCdlTkDataTypeTranslation::Source() const
+	{
+	return iSource;
+	}
+
+bool CCdlTkDataTypeTranslation::Match(const string& aType, string& aTypeVar) const
+	{
+	// KType is the string "aType". If this appears in iType, it matches
+	// any text in aType, and the matching text is placed in aTypeVar, otherwise
+	// aType must equal iType for a match to be found.
+	if (iTypeVarPos == string::npos)
+		{
+		// iType does not contain "aType". Give aTypeVar a dummy result
+		// and compare the two types.
+		aTypeVar = KType;
+		return iType == aType;
+		}
+	else
+		{
+		// iType contains the string "aType", so check if aType is big enough
+		// and that the start matches and the end matches.
+		int aTypeSize = aType.size();
+		if (iTypeSizeWithoutTypeVar >= aTypeSize ||
+			iTextBeforeTypeVar != aType.substr(0, iTypeVarPos) ||
+			iTextAfterTypeVar != aType.substr(aTypeSize - iSizeAfterTypeVar))
+			return false;
+		// Set aTypeVar to be the part of aType that corresponds to the string
+		// "aType".
+		aTypeVar = aType.substr(iTypeVarPos, aTypeSize - iTypeSizeWithoutTypeVar);
+		return true;
+		}
+	}
+
+bool CCdlTkDataTypeTranslation::operator==(const CCdlTkDataTypeTranslation& aOther) const
+	{
+	return
+		iType == aOther.iType &&
+		iDefn == aOther.iDefn &&
+		iPtrRef == aOther.iPtrRef &&
+		iSource == aOther.iSource;
+	}
+
+
+//
+// CCdlTkDataTypeTranslations
+//
+
+CCdlTkDataTypeTranslations::CCdlTkDataTypeTranslations()
+	{
+	// gStdTranslations is defined in CdlTkStdTrans.h
+	int count = sizeof(gStdTranslations)/sizeof(*gStdTranslations);
+	for (int ii=0; ii<count; ii++)
+		{
+		const SStdTranslation& trans = gStdTranslations[ii];
+		push_back(CCdlTkDataTypeTranslation(trans.iType, trans.iInit, trans.iRef, CCdlTkDataTypeTranslation::EInbuilt));
+		}
+	}
+
+void CCdlTkDataTypeTranslations::MergeExtensionTranslations(const CCdlTkDataTypeTranslations& aOther)
+	{
+	for (const_iterator pOther = aOther.begin(); pOther != aOther.end(); ++pOther)
+		{
+		if (pOther->Source() != CCdlTkDataTypeTranslation::EInbuilt)
+			push_back(*pOther);
+		}
+	}
+
+const CCdlTkDataTypeTranslation* CCdlTkDataTypeTranslations::Find(const string& aType, string& aTypeVar) const
+	{
+	for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
+		{
+		if (it->Match(aType, aTypeVar))
+			return &*it;
+		}
+	return NULL;
+	}
+
+
+//
+// CCdlTkInterface
+//
+
+CCdlTkInterface::CCdlTkInterface()
+: iBase(0), iExtension(0)
+	{
+	}
+
+CCdlTkInterface::~CCdlTkInterface()
+	{
+	delete iExtension;
+	}
+
+CCdlTkInterface::CCdlTkInterface(const CCdlTkInterface& aCopy)
+: iBase(0), iExtension(0)
+	{
+	*this = aCopy;
+	}
+
+void CCdlTkInterface::operator=(const CCdlTkInterface& aCopy)
+	{
+	if (&aCopy == this)
+		return;
+
+	iFileName = aCopy.iFileName;
+	iHeader = aCopy.iHeader;
+	iCpp = aCopy.iCpp;
+	iApiList.Copy(aCopy.iApiList, *this);
+	iDataTypeTranslations = aCopy.iDataTypeTranslations;
+	iBase = aCopy.iBase;
+	delete iExtension;
+	iExtension = 0;
+	if (aCopy.iExtension)
+		iExtension = new CCdlTkInterface(*aCopy.iExtension);
+	}
+
+CCdlTkInterface* CCdlTkInterface::Base() const
+	{
+	return iBase;
+	}
+
+void CCdlTkInterface::SetBase(CCdlTkInterface* aBase)
+	{
+	iBase = aBase;
+	}
+
+CCdlTkInterface* CCdlTkInterface::Extension() const
+	{
+	return iExtension;
+	}
+
+void CCdlTkInterface::SetExtension(CCdlTkInterface* aExtension)
+	{
+	delete iExtension;
+	iExtension = aExtension;
+	}
+
+CCdlTkInterface* CCdlTkInterface::UltimateBase()
+	{
+	CCdlTkInterface* base = this;
+	while (base->Base())
+		base = base->Base();
+	return base;
+	}
+
+const CCdlTkInterface* CCdlTkInterface::UltimateBase() const
+	{
+	const CCdlTkInterface* base = this;
+	while (base->Base())
+		base = base->Base();
+	return base;
+	}
+
+CCdlTkInterface* CCdlTkInterface::UltimateExtension()
+	{
+	CCdlTkInterface* extension = this;
+	while (extension->Extension())
+		extension = extension->Extension();
+	return extension;
+	}
+
+const CCdlTkInterface* CCdlTkInterface::UltimateExtension() const
+	{
+	const CCdlTkInterface* extension = this;
+	while (extension->Extension())
+		extension = extension->Extension();
+	return extension;
+	}
+
+void CCdlTkInterface::MergeExtensions()
+	{
+	for (CCdlTkInterface* ext = Extension(); ext; ext = ext->Extension())
+		{
+		iHeader.MergeExtensionHeader(ext->iHeader);
+		iCpp.MergeExtensionCpp(ext->iCpp);
+		iApiList.MergeExtendedApi(*this, ext->iApiList);
+		iDataTypeTranslations.MergeExtensionTranslations(ext->iDataTypeTranslations);
+		}
+	SetExtension(0);
+	}
+
+string CCdlTkInterface::FileName() const
+	{
+	return iFileName;
+	}
+
+void CCdlTkInterface::SetFileName(const string& aFileName)
+	{
+	iFileName = aFileName;
+	}
+
+string CCdlTkInterface::AdditionalComment() const
+	{
+	return iAdditionalComment;
+	}
+
+void CCdlTkInterface::SetAdditionalComment(const string& aAdditionalComment)
+	{
+	iAdditionalComment = aAdditionalComment;
+	}
+
+CCdlTkInterfaceHeader& CCdlTkInterface::Header()
+	{
+	return iHeader;
+	}
+
+const CCdlTkInterfaceHeader& CCdlTkInterface::Header() const
+	{
+	return iHeader;
+	}
+
+CCdlTkCpp& CCdlTkInterface::Cpp()
+	{
+	return iCpp;
+	}
+
+const CCdlTkCpp& CCdlTkInterface::Cpp() const
+	{
+	return iCpp;
+	}
+
+CCdlTkApiList& CCdlTkInterface::ApiList()
+	{
+	return iApiList;
+	}
+
+const CCdlTkApiList& CCdlTkInterface::ApiList() const
+	{
+	return iApiList;
+	}
+
+string CCdlTkInterface::NamespaceName() const
+	{
+	return CdlTkUtil::ToCpp(iHeader.Name());
+	}
+
+CCdlTkDataTypeTranslations& CCdlTkInterface::DataTypeTranslations()
+	{
+	return iDataTypeTranslations;
+	}
+
+const CCdlTkDataTypeTranslations& CCdlTkInterface::DataTypeTranslations() const
+	{
+	return iDataTypeTranslations;
+	}
+
+bool CCdlTkInterface::operator==(const CCdlTkInterface& aOther) const
+	{
+	return
+		iHeader == aOther.iHeader &&
+		iCpp == aOther.iCpp &&
+		iApiList == aOther.iApiList &&
+		iDataTypeTranslations == aOther.iDataTypeTranslations &&
+		!iExtension == !aOther.iExtension &&
+		(!iExtension || *iExtension == *aOther.iExtension);
+	}
+
+
+//
+// CCdlTkInterfaceList
+//
+
+CCdlTkInterfaceList::CCdlTkInterfaceList()
+	{
+	}
+
+CCdlTkInterfaceList::~CCdlTkInterfaceList()
+	{
+	for (iterator it = begin(); it != end(); ++it)
+		delete *it;
+	}
+
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkInterfaceCheck.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include <algorithm>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// CCdlTkApiListComparator
+//
+
+class CCdlTkApiListComparator
+	{
+public:
+	CCdlTkApiListComparator(CCdlTkApiList::const_iterator& aIter) : iIter(aIter) {}
+	bool operator()(const CCdlTkApi* aApi) { return *aApi == **iIter; }
+	CCdlTkApiList::const_iterator& iIter;
+	};
+
+
+//
+// CCdlTkApiChecker
+//
+
+CCdlTkApiChecker::CCdlTkApiChecker(const CCdlTkInterface& aLeft, 
+								   const CCdlTkInterface& aRight, 
+								   MCdlTkApiCheckObserver& aObserver)
+: iLeft(aLeft), iRight(aRight), iObserver(aObserver)
+	{
+	}
+
+CCdlTkApiChecker::~CCdlTkApiChecker()
+	{
+	}
+
+void CCdlTkApiChecker::Process()
+	{
+	iObserver.StartCheck();
+	
+	const CCdlTkApiList& leftList = iLeft.ApiList();
+	const CCdlTkApiList& rightList = iRight.ApiList();
+
+	CApiListIter posLeft = leftList.begin();
+	CApiListIter posRight = rightList.begin();
+	CApiListIter leftEnd = leftList.end();
+	CApiListIter rightEnd = rightList.end();
+	
+	while (posLeft!=leftEnd && posRight!=rightEnd)
+		{
+		// if left and right APIs don't match, 
+		// move the iterators till they do, or they hit the end
+		if (**posLeft != **posRight)
+			ReSync(posLeft, posRight, leftEnd, rightEnd);
+
+		if (posLeft == leftEnd || posRight == rightEnd)
+			{
+			// if either iterator hits the end, fail everything remaining
+			FailLeft(posLeft, leftEnd);
+			FailRight(posRight, rightEnd);
+			}
+		else
+			{
+			// the APIs match, so tell the observer and move on
+			iObserver.ApiInBoth(**posLeft);
+			++posLeft;
+			++posRight;
+			}
+		}
+
+	iObserver.CheckComplete();
+	}
+
+// This function moves the iterators posLeft and posRight onwards till they
+// match APIs again, or they hit the ends.
+void CCdlTkApiChecker::ReSync(CApiListIter& posLeft, CApiListIter& posRight, 
+							  const CApiListIter& leftEnd, const CApiListIter& rightEnd) const
+	{
+	// lookaheadLeft and lookaheadRight are how far we are looking ahead for a match
+	CApiListIter lookaheadLeft = posLeft;
+	CApiListIter lookaheadRight = posRight;
+
+	// predicates for finding an API in a range
+	CCdlTkApiListComparator chkContainsLeft(lookaheadLeft);
+	CCdlTkApiListComparator chkContainsRight(lookaheadRight);
+
+	// keep going till we get a match or reach the end
+	for (;;) 
+		{
+		// move lookahead iterators on one step
+		++lookaheadLeft;
+		++lookaheadRight;
+
+		// stop and fail if we've hit the end on the left
+		if (lookaheadLeft == leftEnd)
+			{
+			FailLeft(posLeft, leftEnd);
+			break;
+			}
+
+		// stop and fail if we've hit the end on the right
+		if (lookaheadRight == rightEnd)
+			{
+			FailRight(posRight, rightEnd);
+			break;
+			}
+
+		// look through LHS lookahead range for the RHS API at the lookahead position
+		CApiListIter foundLeft = find_if(posLeft, lookaheadLeft+1, chkContainsRight);
+		if (foundLeft != lookaheadLeft+1)
+			{
+			// found a match, fail everything up till the match position and stop
+			FailLeft(posLeft, foundLeft);
+			FailRight(posRight, lookaheadRight);
+			break;
+			}
+
+		// look through RHS lookahead range for the LHS API at the lookahead position
+		CApiListIter foundRight = find_if(posRight, lookaheadRight+1, chkContainsLeft);
+		if (foundRight != lookaheadRight+1)
+			{
+			// found a match, fail everything up till the match position and stop
+			FailLeft(posLeft, lookaheadLeft);
+			FailRight(posRight, foundRight);
+			break;
+			}
+		}
+	}
+
+void CCdlTkApiChecker::FailLeft(CApiListIter& aFrom, const CApiListIter& aTo) const
+	{
+	while (aFrom != aTo)
+		{
+		iObserver.ApiNotInRight(**aFrom);
+		++aFrom;
+		}
+	}
+
+void CCdlTkApiChecker::FailRight(CApiListIter& aFrom, const CApiListIter& aTo) const
+	{
+	while (aFrom != aTo)
+		{
+		iObserver.ApiNotInLeft(**aFrom);
+		++aFrom;
+		}
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkPackage.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,302 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkInstance.h"
+#include "CdlTkPriv.h"
+#include <sstream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// PackageErr
+//
+
+class PackageErr : public CdlCompilerToolkitErr
+	{
+public:
+	void Show(ostream& aStream) const;
+	};
+
+void PackageErr::Show(ostream& aStream) const
+	{
+	aStream << "Interface does not define a package";
+	}
+
+
+//
+// CCdlTkPackage::CRef
+//
+
+CCdlTkPackage::CRef::CRef()
+: iId(KCdlTkGetInstanceIdFromHostDll), iUid(0)
+	{
+	}
+
+const string& CCdlTkPackage::CRef::LocalInstanceName() const
+	{
+	return iLocalInstanceName;
+	}
+
+void CCdlTkPackage::CRef::SetLocalInstanceName(const string& aLocalInstanceName)
+	{
+	iLocalInstanceName = aLocalInstanceName;
+	}
+
+int CCdlTkPackage::CRef::Id() const
+	{
+	return iId;
+	}
+
+void CCdlTkPackage::CRef::SetId(int aId)
+	{
+	iId = aId;
+	}
+
+int CCdlTkPackage::CRef::Uid() const
+	{
+	return iUid;
+	}
+
+void CCdlTkPackage::CRef::SetUid(int aUid)
+	{
+	iUid = aUid;
+	}
+
+const string& CCdlTkPackage::CRef::DllName() const
+	{
+	return iDllName;
+	}
+
+void CCdlTkPackage::CRef::SetDllName(const string& aDllName)
+	{
+	iDllName = aDllName;
+	}
+
+const string& CCdlTkPackage::CRef::DllSourcePath() const
+	{
+	return iDllSourcePath;
+	}
+
+void CCdlTkPackage::CRef::SetDllSourcePath(const string& aDllSourcePath)
+	{
+	iDllSourcePath = aDllSourcePath;
+	}
+
+const string& CCdlTkPackage::CRef::DllInstName() const
+	{
+	return iDllInstName;
+	}
+
+void CCdlTkPackage::CRef::SetDllInstName(const string& aDllInstName)
+	{
+	iDllInstName = aDllInstName;
+	}
+
+
+
+//
+// CCdlTkPackage
+//
+
+CCdlTkPackage::CCdlTkPackage(const CCdlTkInterface& aInterface)
+: CCdlTkInstance(aInterface)
+	{
+	iContentsImpl = Impl().Find(KPackageContentsApi);
+	if (!iContentsImpl)
+		throw PackageErr();
+	GenerateImpl();
+	}
+
+CCdlTkPackage::~CCdlTkPackage()
+	{
+	}
+
+void CCdlTkPackage::AddLocalContent(const CCdlTkInstance& aInstance)
+	{
+	CRef ref;
+	ref.SetLocalInstanceName(aInstance.Name());
+	iContents.push_back(ref);
+	GenerateImpl();
+	}
+
+void CCdlTkPackage::AddLocalContent(const string& aLocalInstanceName)
+	{
+	CRef ref;
+	ref.SetLocalInstanceName(aLocalInstanceName);
+	iContents.push_back(ref);
+	GenerateImpl();
+	}
+
+void CCdlTkPackage::AddContent(const CCdlTkInstance& aInstance, const CCdlTkDll& aDll, const std::string& aDllSourcePath)
+	{
+	CRef ref;
+	ref.SetId(aInstance.Id());
+	ref.SetUid(aInstance.Interface().Header().Uid());
+	ref.SetDllName(aDll.Name());
+	ref.SetDllSourcePath(aDllSourcePath);
+	ref.SetDllInstName(aInstance.DllInstanceName());
+	iContents.push_back(ref);
+	GenerateImpl();
+	}
+
+void CCdlTkPackage::AddContent(int aId, int aUid, const string& aDllName)
+	{
+	CRef ref;
+	ref.SetId(aId);
+	ref.SetUid(aUid);
+	ref.SetDllName(aDllName);
+	iContents.push_back(ref);
+	GenerateImpl();
+	}
+
+void CCdlTkPackage::AddExternalContent(const string& aInstanceName, const string& aDllSourcePath, const string& aDllName)
+	{
+	CRef ref;
+	ref.SetDllInstName(aInstanceName);
+	ref.SetDllName(aDllName);
+	ref.SetDllSourcePath(aDllSourcePath);
+	iContents.push_back(ref);
+	GenerateImpl();
+	}
+
+const CCdlTkPackage::CRefs& CCdlTkPackage::Contents() const
+	{
+	return iContents;
+	}
+
+const string KArrayStart = "\
+\n\
+CDL_ARRAY_START(TCdlRef, contents)\n\
+\t{\n";
+
+const string KArrayEnd = "\
+\t}\n\
+CDL_ARRAY_END(TCdlRef, contents);\n";
+
+void CCdlTkPackage::GenerateImpl()
+	{
+	string defn;
+
+	if (iContents.empty())
+		{
+		defn = "EMPTY_CDL_ARRAY(TCdlRef, contents)\n";
+		}
+	else
+		{
+		set<string> dllNames;
+		AddIncludesAndBuildDllSet(defn, dllNames);
+		AddDllNameLits(defn, dllNames);
+		CdlTkUtil::AppendString(defn, KArrayStart);
+		AddContents(defn);
+		CdlTkUtil::AppendString(defn, KArrayEnd);
+		}
+
+	iContentsImpl->SetDefinition(defn);
+	}
+
+const string KInclude = "#include \"$NAME\"\n";
+
+void CCdlTkPackage::AddIncludesAndBuildDllSet(string& aDefn, set<string>& aDllNames)
+	{
+	for (CRefs::iterator pRef = iContents.begin(); pRef != iContents.end(); ++pRef)
+		{
+		CRef& ref = *pRef;
+		string locInst = CdlTkUtil::ToLower(ref.LocalInstanceName());
+		if (locInst.empty())
+			{
+			// if it's not a local instance, add its dll name to the set
+			string dllName = ref.DllName();
+			if (!dllName.empty())
+				aDllNames.insert(dllName);
+
+			// if the instance id comes from its host DLL, #include the host DLL ids
+			if (ref.Id() == KCdlTkGetInstanceIdFromHostDll)
+				{
+				string include = CdlTkUtil::ToLower(ref.DllSourcePath() + KDllInstHeader);
+				CdlTkUtil::AppendString(aDefn, CdlTkUtil::Replace("$NAME", include, KInclude));
+				include = CdlTkUtil::ToLower(ref.DllSourcePath() + ref.DllInstName() + ".h");
+				CdlTkUtil::AppendString(aDefn, CdlTkUtil::Replace("$NAME", include, KInclude));
+				}
+			}
+		else
+			{
+			// #include local instances
+			CdlTkUtil::AppendString(aDefn, CdlTkUtil::Replace("$NAME", locInst+".h", KInclude));
+			}
+		}
+	}
+
+const string KDllLit = "_LIT(_content_DLL_$CPP_NAME, \"$DLL_NAME\");\n";
+
+void CCdlTkPackage::AddDllNameLits(string& aDefn, set<string>& aDllNames)
+	{
+	// add literals for all of the DLL names
+	for (set<string>::iterator pDll = aDllNames.begin(); pDll != aDllNames.end(); ++pDll)
+		{
+		CdlTkUtil::AppendString(aDefn, 
+			CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(*pDll), 
+				CdlTkUtil::Replace("$DLL_NAME", *pDll, KDllLit)));
+		}
+	}
+
+const string KLocRef = "\tLOCAL_CDL_REF($NAME),\n";
+
+void CCdlTkPackage::AddContents(string& aDefn)
+	{
+	for (CRefs::iterator pRef = iContents.begin(); pRef != iContents.end(); ++pRef)
+		{
+		string locInst = pRef->LocalInstanceName();
+		if (locInst.empty())
+			{
+			// if it's not a local instance use {} intialisation
+			string id;
+			string uid;
+			if (pRef->Id() == KCdlTkGetInstanceIdFromHostDll)
+				{
+				id = pRef->DllInstName() + "::KCdlInstanceId";
+				uid = pRef->DllInstName() + "::KCdlInterfaceUidValue";
+				}
+			else
+				{
+				id = CdlTkUtil::IntToString(pRef->Id());
+				uid = pRef->Uid();
+				}
+
+			stringstream ref;
+			ref << "\t{" << id << ", " << uid << ", ";
+
+			// empty DLL name implies that the instance is in the same DLL,
+			// use use a null pointer, otherwise use the literal
+			string dllName = pRef->DllName();
+			if (dllName.empty())
+				ref << "NULL";
+			else
+				ref << "LIT_AS_DESC_PTR(_content_DLL_" << CdlTkUtil::ToCpp(dllName) << ")";
+			ref << "},\n";
+
+			CdlTkUtil::AppendString(aDefn, ref.str());
+			}
+		else
+			{
+			// local instances use the LOCAL_CDL_REF macro.
+			CdlTkUtil::AppendString(aDefn, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToCpp(locInst), KLocRef));
+			}
+		}
+	}
+
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkParser.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,362 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <iomanip>
+#include <sstream>
+#include <iostream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// SyntaxErr
+//
+
+class SyntaxErr : public CdlCompilerToolkitErr
+	{
+public:
+	SyntaxErr(const string& aFileName, int aLineNo, string aErr);
+	void Show(ostream& aStream) const;
+private:
+	string iFileName;
+	int iLineNo;
+	string iErr;
+	};
+
+SyntaxErr::SyntaxErr(const string& aFileName, int aLineNo, string aErr)
+: iFileName(aFileName), iLineNo(aLineNo), iErr(aErr)
+	{
+	}
+
+void SyntaxErr::Show(ostream& aStream) const
+	{
+	aStream << iFileName << "(" << iLineNo << ")" << " : error : " << iErr << endl;
+	}
+
+
+//
+// CCdlTkCdlFileParser
+//
+
+CCdlTkCdlFileParser::CCdlTkCdlFileParser(const string& aFileName) 
+: iFileName(aFileName)
+	{
+	}
+
+CCdlTkCdlFileParser::~CCdlTkCdlFileParser()
+	{
+	CloseStream();
+	}
+
+void CCdlTkCdlFileParser::Process()
+	{
+	throw CdlTkAssert("Sorry, CCdlTkCdlFileParser::Process() does not exist, call LoadAndParse() instead");
+	}
+
+auto_ptr<CCdlTkInterface> CCdlTkCdlFileParser::LoadAndParse(bool aMergeExtensions)
+	{
+	OpenStream();
+	iState = EHeader;
+	auto_ptr<CCdlTkInterface> cdl(new CCdlTkInterface);
+	cdl->SetFileName(iFileName);
+	ParseStream(*cdl.get());
+	CloseStream();
+	if (aMergeExtensions)
+		cdl->MergeExtensions();
+	return cdl;
+	}
+
+void CCdlTkCdlFileParser::OpenStream()
+	{
+	CdlTkUtil::OpenInput(iIn, iFileName);
+	iCurrentSourceLineNum = 0;
+	}
+
+void CCdlTkCdlFileParser::ParseStream(CCdlTkInterface& aCdl)
+	{
+	CCdlTkInterface* cdl = &aCdl;
+	while (!iIn.eof())
+		{
+		string line = GetLine();
+		TParseState newState = iState;
+		if (IsSectionBoundary(line, newState))
+			{
+			iState = newState;
+			if (iState == EHeader && !(cdl->Header() == CCdlTkInterfaceHeader()))
+				{
+				CCdlTkInterface* ext = new CCdlTkInterface;
+				ext->SetBase(cdl);
+				cdl->SetExtension(ext);
+				cdl = ext;
+				}
+			// iApiBuf and iComment have to be cleared over a section boundary
+			iApiBuf = "";
+			iComment = "";
+			}
+		else
+			{
+			switch (iState)
+				{
+				case EHeader: 
+					ParseHeader(*cdl, line); 
+					break;
+				case ECpp: 
+					ParseCpp(*cdl, line); 
+					break;
+				case ETranslation: 
+					ParseTranslationLine(*cdl, line); 
+					break;
+				case EApi: 
+					ParseApi(*cdl, line); 
+					break;
+				default: 
+					return;
+				}
+			}
+		}
+	}
+
+void CCdlTkCdlFileParser::CloseStream()
+	{
+	iIn.close();
+	}
+
+void CCdlTkCdlFileParser::ParseHeader(CCdlTkInterface& aCdl, const string& aLine)
+	{
+	string val;
+	if (MatchLineStart(aLine, "Name:", val))
+		{
+		aCdl.Header().SetName(val);
+		}
+	else if (MatchLineStart(aLine, "Version:", val))
+		{
+		int major, minor;
+		char c;
+		stringstream s(val);
+		s >> major >> c >> minor;
+		if (c != '.' || !s.eof())
+			SyntaxError(string("Invalid version number ") + val);
+		aCdl.Header().SetVersion(CCdlTkInterfaceHeader::CVersion(major, minor));
+		}
+	else  if (MatchLineStart(aLine, "UID:", val))
+		{
+		aCdl.Header().SetUid(CdlTkUtil::ParseInt(val));
+		}
+	else if (MatchLineStart(aLine, "Flag:", val))
+		{
+		aCdl.Header().Flags().SetFlag(val);
+		}
+	}
+
+void CCdlTkCdlFileParser::ParseCpp(CCdlTkInterface& aCdl, const string& aLine)
+	{
+	aCdl.Cpp().push_back(aLine);
+	}
+
+void CCdlTkCdlFileParser::ParseTranslationLine(CCdlTkInterface& aCdl, const string& aLine)
+	{
+	string line = aLine;
+	StripComments(line, iComment);
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(line);
+	if (!line.empty())
+		{
+		CCdlTkDataTypeTranslation trans;
+		ParseTranslationText(trans, line);
+		aCdl.DataTypeTranslations().push_back(trans);
+		}
+	}
+
+void CCdlTkCdlFileParser::ParseApi(CCdlTkInterface& aCdl, const string& aLine)
+	{
+	string line = aLine;
+	StripComments(line, iComment);
+	if (!line.empty())
+		{
+		// add the line to the API buffer
+		CdlTkUtil::AppendString(iApiBuf, line);
+		int pos;
+		// extract API declarations from the API buffer, separated by semi-colons
+		while ((pos = iApiBuf.find_first_of(';')) != string::npos)
+			{
+			// extract API declaration from API buf and create API from it
+			line = iApiBuf.substr(0, pos);
+			CdlTkUtil::StripLeadingAndTrailingWhitespace(line);
+			auto_ptr<CCdlTkApi> api(CreateApi(aCdl, line));
+			aCdl.ApiList().push_back(api.get());
+			api.release();
+			// remove API declaration from API buf
+			iApiBuf = iApiBuf.substr(pos+1);
+			}
+		}
+	}
+
+string CCdlTkCdlFileParser::GetLine()
+	{
+	string line;
+	getline(iIn, line);
+	iCurrentSourceLineNum++;
+	return line;
+	}
+
+bool CCdlTkCdlFileParser::IsSectionBoundary(const string& aLine, TParseState& aState)
+	{
+	string section;
+	bool isBoundary = MatchLineStart(aLine, KSectionBoundary, section);
+	if (!isBoundary)
+		return false;
+
+	section = CdlTkUtil::ToLower(section);
+
+	char* sections[] = {"header", "c++", "translation", "api", "end"};
+	TParseState s;
+	for (s = EHeader; s < EParseStateCount; s = TParseState(s+1))
+		if (section == sections[s])
+			break;
+	if (s < EParseStateCount)
+		aState = s;
+	else 
+		SyntaxError("Unrecognised section type : " + section);
+
+	return true;
+	}
+
+bool CCdlTkCdlFileParser::MatchLineStart(const string& aLine, const string& aHeader, string& aVal)
+	{
+	if (aLine.size() < aHeader.size() || aLine.substr(0, aHeader.size()) != aHeader)
+		return false;
+
+	aVal = aLine.substr(aHeader.size());
+	StripComments(aVal, iComment);
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(aVal);
+	return true;
+	}
+
+void CCdlTkCdlFileParser::StripComments(string& aStr, string& aComment)
+	{
+	int pos = aStr.find(KCommentStart);
+	if (pos != string::npos)
+		{
+		aComment += aStr.substr(pos) + "\n";
+		}
+	aStr = aStr.substr(0, pos);
+	}
+
+auto_ptr<CCdlTkApi> CCdlTkCdlFileParser::CreateApi(CCdlTkInterface& aCdl, string& aLine)
+	{
+	auto_ptr<CCdlTkApi> pApi;
+	bool isFunc = (aLine[aLine.size()-1] == ')');	// function APIs end with ')', data APIs don't
+	if (isFunc)
+		{
+		auto_ptr<CCdlTkFunctionApi> pFuncApi(new CCdlTkFunctionApi(aCdl));
+		int paramStart = aLine.find('(');
+		if (paramStart == string::npos)
+			SyntaxError("function has missing '('");
+		string params = aLine.substr(paramStart);
+		aLine = aLine.substr(0, paramStart);
+		params = params.substr(1, params.size()-2);		// -2 for opening and closing brackets
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(params);
+		ParseApiParams(pFuncApi->Params(), params);
+		pApi = auto_ptr<CCdlTkApi>(pFuncApi.release());
+		}
+	else
+		{
+		pApi = auto_ptr<CCdlTkApi>(new CCdlTkDataApi(aCdl));
+		}
+	string name, type, defaultValue;
+	ParseNameTypeAndDefaultValue(aLine, name, type, defaultValue);
+	pApi->SetName(name);
+	pApi->SetReturnType(type);
+	pApi->SetSourceFileLineNum(iCurrentSourceLineNum);
+	pApi->SetComment(iComment);
+	iComment = "";
+	return pApi;
+	}
+
+void CCdlTkCdlFileParser::ParseApiParams(CCdlTkApiParams& aParams, string& aList)
+	{
+	while (aList.size())
+		{
+		int pos = aList.find(',');
+		string param = aList.substr(0, pos);
+		aList = aList.substr(param.size() + (pos == string::npos ? 0 : 1));
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(aList);
+
+		string name, type, defaultValue;
+		ParseNameTypeAndDefaultValue(param, name, type, defaultValue);
+
+		aParams.push_back(CCdlTkApiParam(type, name, defaultValue));
+		}
+	}
+
+void CCdlTkCdlFileParser::ParseNameTypeAndDefaultValue(string& aStr, string& aName, string& aType, string& aDefaultValue)
+	{
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(aStr);
+	int eq = aStr.find_last_of(KEqualsSign);
+	if(eq != string::npos)
+		{
+		aDefaultValue = aStr.substr(eq + 1);
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(aDefaultValue);
+
+		aStr = aStr.substr(0, eq);
+		CdlTkUtil::StripLeadingAndTrailingWhitespace(aStr);
+		}
+
+	int pos = aStr.find_last_not_of(KCpp);
+	aName = aStr.substr(pos + 1);
+	aStr = aStr.substr(0, pos);
+
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(aStr);
+	aType = aStr;
+	}
+
+void CCdlTkCdlFileParser::ParseTranslationText(CCdlTkDataTypeTranslation& aTrans, string& aLine)
+	{
+	int pos1 = aLine.find('#');
+	if (pos1 == string::npos)
+		SyntaxError("First # not found");
+	int pos2 = aLine.find('#', pos1+1);
+	if (pos2 == string::npos)
+		SyntaxError("Second # not found");
+	if (aLine.find('#', pos2+1) != string::npos)
+		SyntaxError("Third # found");
+
+	string type = aLine.substr(0, pos1++);
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(type);
+
+	string defn = aLine.substr(pos1, pos2-pos1);
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(defn);
+	if (defn.find("aName") == string::npos)
+		SyntaxError("\"aName\" not found in definition");
+
+	string ptrRef = aLine.substr(pos2+1);
+	CdlTkUtil::StripLeadingAndTrailingWhitespace(ptrRef);
+	if (ptrRef.find("aName") == string::npos)
+		SyntaxError("\"aName\" not found in pointer reference");
+
+	aTrans.SetType(type);
+	aTrans.SetDefinition(defn);
+	aTrans.SetPointerReference(ptrRef);
+	}
+
+void CCdlTkCdlFileParser::SyntaxError(const string& aErr)
+	{
+	throw SyntaxErr(iFileName, iCurrentSourceLineNum, aErr);
+	}
+
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkProcess.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <stdio.h>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+CCdlTkProcess::~CCdlTkProcess()
+	{
+	}
+
+string CCdlTkProcess::CdlBaseNameAndPath(const CCdlTkInterface& aCdl)
+	{
+	return CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + CdlTkUtil::StripPath(aCdl.FileName()));
+	}
+
+void CCdlTkProcess::AssertInterfaceNotExtended(const CCdlTkInterface& aCdl)
+	{
+	if (aCdl.Base() || aCdl.Extension())
+		throw CdlTkAssert("Can't process extended interface - merge extensions first");
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkSourceFileWriter.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,63 @@
+/*
+* 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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+
+CCdlTkSourceFileWriter::~CCdlTkSourceFileWriter()
+	{
+	}
+
+void CCdlTkSourceFileWriter::WriteNamespaceStart(const CCdlTkInterface& aCdl, ofstream& aStream) const
+	{
+	aStream << "namespace " << aCdl.NamespaceName()	<< endl;
+	aStream << "{" << endl;
+	}
+
+void CCdlTkSourceFileWriter::WriteNamespaceEnd(const CCdlTkInterface& aCdl, ofstream& aStream) const
+	{
+	aStream << "} // end of namespace " << aCdl.NamespaceName() << endl;
+	}
+
+std::string CCdlTkSourceFileWriter::HeaderGuardName(const std::string& aFileName) const
+	{
+	return CdlTkUtil::ToUpper(CdlTkUtil::ToCpp(CdlTkUtil::StripPath(aFileName)));
+	}
+
+void CCdlTkSourceFileWriter::WriteHeaderGuardStart(const string& aName, ofstream& aStream) const
+	{
+	string defName = HeaderGuardName(aName);
+	aStream << "#ifndef " << defName << endl;
+	aStream << "#define " << defName << endl;
+	aStream << endl;
+	}
+
+void CCdlTkSourceFileWriter::WriteHeaderGuardEnd(const string& aName, ofstream& aStream) const
+	{
+	string defName = HeaderGuardName(aName);
+	aStream << endl;
+	aStream << "#endif // " << defName << endl;
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkSyntaxCheck.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,131 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <direct.h>
+#include <iostream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// CppSyntaxErr
+//
+
+class CppSyntaxErr : public CdlCompilerToolkitErr
+	{
+public:
+	CppSyntaxErr(int aErr);
+	void Show(ostream& aStream) const;
+private:
+	int iErr;
+	};
+
+CppSyntaxErr::CppSyntaxErr(int aErr)
+: iErr(aErr)
+	{
+	}
+
+void CppSyntaxErr::Show(ostream& aStream) const
+	{
+	aStream << "CDL C++ Syntax check failed. Cpp returned " << iErr << endl;
+	}
+
+
+//
+// CCdlTkSyntaxCheck
+//
+
+CCdlTkSyntaxCheck::CCdlTkSyntaxCheck(const CCdlTkInterface& aCdl)
+: CCdlTkWriteClientHeader(aCdl)
+	{
+	}
+
+CCdlTkSyntaxCheck::~CCdlTkSyntaxCheck()
+	{
+	}
+
+void CCdlTkSyntaxCheck::Process()
+	{
+	AssertInterfaceNotExtended(iCdl);
+	string name = iCdl.FileName() + ".tempCdlSyntaxCheck";
+
+	// these will automatically delete the files when the function returns
+	CCdlTkFileCleanup cppClean(name + ".cpp");
+	CCdlTkFileCleanup objClean(name + ".s");
+
+	WriteSyntaxCheckCpp(name + ".cpp");
+	DoSyntaxCheckBuild(name + ".cpp");
+	}
+
+void CCdlTkSyntaxCheck::WriteSyntaxCheckCpp(string aName) const
+	{
+	ofstream out;
+	CdlTkUtil::OpenOutput(out, aName);
+
+	out << "#line 1 \"" << CdlTkUtil::StripPath(iCdl.FileName()) << "\"" << endl;
+	out << "#include <cdlengine.h>" << endl;
+	const CCdlTkCpp& cpp = iCdl.Cpp();
+	for (CCdlTkCpp::const_iterator pCpp = cpp.begin(); pCpp != cpp.end(); ++pCpp)
+		{
+		out << *pCpp << endl;
+		}
+	WriteNamespaceStart(iCdl, out);
+	for (CCdlTkApiList::const_iterator pApi = iCdl.ApiList().begin(); pApi != iCdl.ApiList().end(); ++pApi)
+		WriteSyntaxCheckApi(**pApi, out);
+	WriteNamespaceEnd(iCdl, out);
+	out << "GLDEF_C TInt E32Dll(TDllReason /*aReason*/)" << endl;
+	out << "\t{" << endl;
+	out << "\treturn(KErrNone);" << endl;
+	out << "\t}" << endl;
+
+	out.close();
+	}
+
+void CCdlTkSyntaxCheck::DoSyntaxCheckBuild(string aName) const
+	{
+	string s = "gcc ";
+	if (!iParams.empty())
+		{
+		s += "\"";
+		s += iParams;
+		s += "\" ";
+		}
+	s += "-Wp,-DNDEBUG,-D_UNICODE,-D__SYMBIAN32__,-D__GCC32__,-D__EPOC32__,-D__MARM__,-D__MARM_ARMI__,-D__DLL__,-I";
+	s += CdlTkUtil::CurrentDrive();	// drive
+	s += "\\epoc32\\include -S -xc++ ";
+	s += CdlTkUtil::CurrentDrive();	// drive
+	s += aName;
+	int err = system(s.c_str());
+	if (err)
+		throw CppSyntaxErr(err);
+	}
+
+void CCdlTkSyntaxCheck::WriteSyntaxCheckApi(const CCdlTkApi& aApi, ofstream& aStream) const
+	{
+	aStream << "#line " << setbase(10) << aApi.SourceFileLineNum() << endl;
+	aStream << ClientReturnType(aApi) << " " << aApi.Name() << aApi.ParamsTypeAndNameList() << ";" << endl;
+	}
+
+void CCdlTkSyntaxCheck::SetParams(string aParams)
+	{
+	iParams = aParams;
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkUtil.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,561 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlTkPriv.h"
+
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iomanip>
+#include <direct.h>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+//
+// CdlCompilerToolkitErr
+//
+
+CdlCompilerToolkitErr::~CdlCompilerToolkitErr()
+	{
+	}
+
+
+//
+// CCdlTkFileCleanup
+//
+
+CCdlTkFileCleanup::CCdlTkFileCleanup()
+: iName("")
+	{
+	}
+
+CCdlTkFileCleanup::CCdlTkFileCleanup(const std::string& aName)
+: iName(aName)
+	{
+	}
+
+CCdlTkFileCleanup::~CCdlTkFileCleanup()
+	{
+	Cleanup();
+	}
+
+void CCdlTkFileCleanup::Set(const string& aName)
+	{
+	iName = aName;
+	}
+
+void CCdlTkFileCleanup::Cleanup()
+	{
+	if (!iName.empty())
+		CdlTkUtil::DeleteFile(iName);
+	Release();
+	}
+
+string CCdlTkFileCleanup::Name() const
+	{
+	return iName;
+	}
+
+void CCdlTkFileCleanup::Release()
+	{
+	iName.erase();
+	}
+
+
+//
+// CdlTkAssert
+//
+
+CdlTkAssert::CdlTkAssert(const string& aText)
+: iText(aText)
+	{
+	}
+
+void CdlTkAssert::Show(ostream& stream) const
+	{
+	stream << "Cdl Compiler Toolkit assertion failed : " << iText << endl;
+	}
+
+
+//
+// CdlTkFileOpenErr
+//
+
+CdlTkFileOpenErr::CdlTkFileOpenErr(const string& aFileName) : iFileName(aFileName)
+	{
+	}
+
+void CdlTkFileOpenErr::Show(ostream& stream) const
+	{
+	stream << endl;
+	stream << iFileName << " failed to open" << endl;
+	}
+
+
+//
+// CdlTkUtil
+//
+
+string CdlTkUtil::CurrentDrive()
+	{
+	static string drive = "?:";
+	if (drive == "?:")
+		drive[0] = 'A' + _getdrive() - 1;
+	return drive;
+	}
+
+string CdlTkUtil::CurrentDir()
+	{
+	static string dir = "";
+	if (dir == "")
+		{
+		char buf[256];
+		dir = _getcwd(buf, 255) + 2;	// +2 removes drive
+		dir += "\\";
+		}
+	return dir;
+	}
+
+static string gOutputPath = "";
+
+string CdlTkUtil::OutputPath()
+	{
+	if (gOutputPath == "")
+		gOutputPath = CurrentDir();
+	return gOutputPath;
+	}
+
+void CdlTkUtil::SetOutputPath(const string& aPath)
+	{
+	gOutputPath = aPath;
+	if (gOutputPath.size() == 0)
+		gOutputPath += ".\\";
+	else if (gOutputPath[gOutputPath.size()-1] != '\\')
+		gOutputPath += "\\";	// CDL Tk convention is that paths always end in \ 
+	}
+
+string CdlTkUtil::ToLower(const string& aString)
+	{
+	string r;
+	r.resize(aString.size());
+	transform(aString.begin(), aString.end(), r.begin(), tolower);
+	return r;
+	}
+
+string CdlTkUtil::ToUpper(const string& aString)
+	{
+	string r;
+	r.resize(aString.size());
+	transform(aString.begin(), aString.end(), r.begin(), toupper);
+	return r;
+	}
+
+string CdlTkUtil::ToCpp(const string& aString)
+	{
+	string r = aString;
+	for (string::iterator pC = r.begin(); pC != r.end(); ++pC)
+		{
+		if (!CdlTkUtil::IsCpp(*pC))
+			*pC = '_';
+		}
+	if (r.empty() || CdlTkUtil::IsNumeric(r[0]))
+		r = string("_") + r;
+	return r;
+	}
+
+string CdlTkUtil::StripPath(const string& aPath)
+	{
+	return aPath.substr(aPath.rfind('\\')+1);
+	}
+
+string CdlTkUtil::ResolvePath(const string& aPath, const string& aFileName)
+	{
+	int size = aFileName.size();
+	// if aFileName is absolute, return it
+	if (size > 0 && aFileName[0] == '\\' || size > 1 && aFileName[1] == ':')
+		return aFileName;
+
+	string path = aPath;
+	string file = aFileName;
+
+	// while file starts with a '.', chop file head directory and path tail directory if necessary
+	while (file.size() > 0 && file[0]=='.')
+		{
+		// if file starts with a "..", chop the tail directory off the path
+		if (file.size() > 1 && file[1]=='.' && !path.empty())
+			{
+			path.resize(path.size()-1);			// remove the last slash
+			path.resize(path.rfind('\\')+1);	// remove everything after the next last slash
+			}
+
+		// chop the head directory off the file - it has to have a '\' if it has a '.'
+		int fileSlashPos = file.find('\\');
+		if (fileSlashPos == string::npos)
+			throw CdlTkAssert("Illegal filename");
+		file = file.substr(fileSlashPos + 1);
+		}
+
+	// join remaining path and file
+	return path + file;
+	}
+
+string CdlTkUtil::CapitalizeFilename(const string& aString)
+	{
+	// convert the whole thing to lower case
+	string res = ToLower(aString);
+	// find the first character after the last \ - will be 0 if no \ is present.
+	int filenamePos = res.find_last_of('\\') + 1;
+	if (filenamePos >= res.size())
+		throw CdlTkAssert(aString + " has no filename");
+	// uppercase the first character
+	res[filenamePos] = toupper(res[filenamePos]);
+	cerr << "Warning, filename capitalized: " << res << endl;
+	return res;
+	}
+
+string CdlTkUtil::CorrectFilenameCase(const string& aString)
+	{
+	// The current standard is to set the filename and path to lower case.
+	return ToLower(aString);
+	}
+
+string CdlTkUtil::Replace(const string& aTarget, const string& aWith, const string& aIn)
+	{
+	string ret;
+	int pos=0;
+	int lastMatch = 0;
+	int targetMatch = 0;
+	int targetSize = aTarget.size();
+	int inSize = aIn.size();
+	while (pos < inSize)
+		{
+		if (aTarget[targetMatch] == aIn[pos++])
+			{
+			++targetMatch;
+			if (targetMatch == targetSize)
+				{
+				AppendString(ret, aIn.substr(lastMatch, pos - targetMatch - lastMatch));
+				AppendString(ret, aWith);
+				lastMatch = pos;
+				targetMatch = 0;
+				}
+			}
+		else
+			{
+			targetMatch = 0;
+			}
+		}
+	AppendString(ret, aIn.substr(lastMatch));
+	return ret;
+	}
+
+void CdlTkUtil::ExportFile(CCdlTkFileCleanup& aSourceFile, const string& aExport, ios_base::openmode aOpenMode)
+	{
+	if (!FilesAreIdentical(aSourceFile.Name(), aExport, aOpenMode))
+		{
+		CopyFile(aSourceFile.Name(), aExport, aOpenMode);
+		}
+	aSourceFile.Cleanup();
+	}
+
+void CdlTkUtil::ExportFileIfWritable(CCdlTkFileCleanup& aSourceFile, const string& aExport, ios_base::openmode aOpenMode)
+	{
+	if (!FilesAreIdentical(aSourceFile.Name(), aExport, aOpenMode))
+		{
+		try
+			{
+			CopyFile(aSourceFile.Name(), aExport, aOpenMode);
+			}
+		catch (const CdlTkFileOpenErr& /*e*/)
+			{
+			cerr << "Could not write to " << aExport << endl;
+			}
+		}
+	aSourceFile.Cleanup();
+	}
+
+void CdlTkUtil::DeleteFile(const std::string& aFileName)
+	{
+	remove(aFileName.c_str());
+	}
+
+void CdlTkUtil::CopyFile(const std::string& aSourceFileName, const std::string& aDestinationFileName, ios_base::openmode aOpenMode)
+	{
+	ifstream from;
+	OpenInput(from, aSourceFileName, aOpenMode);
+	ofstream to;
+	OpenOutput(to, aDestinationFileName, aOpenMode);
+
+	const int KSize = 1024;
+	char buf[KSize+1];
+	while (!from.eof())
+		{
+		from.read(buf,KSize);
+		to.write(buf, from.gcount());
+		}
+
+	from.close();
+	to.close();
+	}
+
+bool CdlTkUtil::FilesAreIdentical(const std::string& aLeftFileName, const std::string& aRightFileName, ios_base::openmode aOpenMode)
+	{
+	bool different = false;
+	ifstream leftFile(aLeftFileName.c_str(), aOpenMode);
+	ifstream rightFile(aRightFileName.c_str(), aOpenMode);
+
+	const int KSize = 1024;
+	char left[KSize+1];
+	char right[KSize+1];
+
+	while (!leftFile.eof() && !rightFile.eof())
+		{
+		int gotLeft = leftFile.read(left,KSize).gcount();
+		int gotRight = rightFile.read(right,KSize).gcount();
+
+		if (gotLeft != gotRight || memcmp(left, right, gotLeft) != 0)
+			{
+			different = true;
+			break;
+			}
+		}
+
+	if (leftFile.eof() != rightFile.eof())
+		different = true;
+
+	leftFile.close();
+	rightFile.close();
+
+	return !different;
+	}
+
+void CdlTkUtil::OpenTempOutput(ofstream& aStream, CCdlTkFileCleanup& aFile, ios_base::openmode aOpenMode)
+	{
+	char tmpName[256];
+	if (!tmpnam(tmpName))
+		{
+		throw CdlTkAssert("Can't create temporary file name");
+		}
+
+	OpenOutput(aStream, tmpName, aOpenMode);
+	aFile.Set(tmpName);
+	}
+
+void CdlTkUtil::OpenOutput(ofstream& aStream, const string& aFileName, ios_base::openmode aOpenMode)
+	{
+	aStream.open(aFileName.c_str(), aOpenMode);
+	if (!aStream.is_open())
+		{
+		throw CdlTkFileOpenErr(aFileName);
+		}
+	}
+
+void CdlTkUtil::OpenInput(ifstream& aStream, const string& aFileName, ios_base::openmode aOpenMode)
+	{
+	aStream.open(aFileName.c_str(), aOpenMode);
+	if (!aStream.is_open())
+		throw CdlTkFileOpenErr(aFileName);
+	}
+
+int CdlTkUtil::ParseInt(const string& aInt)
+	{
+	int base = 10;
+	if (aInt.size() > 1 && aInt[0] == '0')
+		{
+		base = 8;
+		if (aInt[1] == 'x')
+			base = 16;
+		}
+
+	int val = 0;
+	stringstream s(aInt);
+	s >> setbase(base) >> val;
+	return val;
+	}
+
+string CdlTkUtil::IntToString(int aInt)
+	{
+	stringstream s;
+	s << aInt;
+	return s.str();
+	}
+
+string CdlTkUtil::IntToHexString(int aInt)
+	{
+	stringstream s;
+	s << "0x" << setw(8) << setfill('0') << hex << aInt;
+	return s.str();
+	}
+
+char* gHexDigits = "0123456789abcdef";
+string CdlTkUtil::ShortToHexString(short aInt)
+	{
+	char s[7] = "0x0000";
+	s[2]=gHexDigits[(aInt>>12)&0xf];
+	s[3]=gHexDigits[(aInt>>8)&0xf];
+	s[4]=gHexDigits[(aInt>>4)&0xf];
+	s[5]=gHexDigits[aInt&0xf];
+	return s;
+	}
+
+string CdlTkUtil::CharToHexString(char aInt)
+	{
+	char s[5] = "0x00";
+	s[2]=gHexDigits[(aInt>>4)&0xf];
+	s[3]=gHexDigits[aInt&0xf];
+	return s;
+	}
+
+void CdlTkUtil::StripLeadingAndTrailingWhitespace(string& aStr)
+	{
+	int pos = aStr.find_first_not_of(KWhiteSpace);
+	if (pos == string::npos)
+		{
+		aStr = KEmptyString;
+		}
+	else
+		{
+		aStr = aStr.substr(pos, aStr.find_last_not_of(KWhiteSpace) + 1 - pos);
+		}
+	}
+
+bool CdlTkUtil::IsAlpha(char aChar)
+	{
+	return ('A' <= aChar && aChar <= 'Z') || ('a' <= aChar && aChar <= 'z');
+	}
+
+bool CdlTkUtil::IsNumeric(char aChar)
+	{
+	return '0' <= aChar && aChar <= '9';
+	}
+
+bool CdlTkUtil::IsCpp(char aChar)
+	{
+	return IsAlpha(aChar) || IsNumeric(aChar) || aChar == '_';
+	}
+
+void ZeroInts(int* aInts, int aCount)
+	{
+	for (int ii=0; ii<aCount; ii++)
+		aInts[ii] = 0;
+	}
+
+string CdlTkUtil::MultiReplace(const CReplaceSet& aSet, const string& aIn)
+	{
+	string ret;
+	int setCount = aSet.size();
+	int* match = new int[setCount];
+	if (!match)
+		throw bad_alloc();
+	ZeroInts(match, setCount);
+
+	int inSize = aIn.size();
+	int pos = 0;
+	int lastMatch = 0;
+	while (pos < inSize)
+		{
+		char ch = aIn[pos++];
+		for (int ii=0; ii<setCount; ii++)
+			{
+			const string& target = aSet[ii].first;
+			int& targetMatch = match[ii];
+			if (target[targetMatch] == ch)
+				{
+				++targetMatch;
+				if (targetMatch == target.size())
+					{
+					AppendString(ret, aIn.substr(lastMatch, pos - targetMatch - lastMatch));
+					AppendString(ret, aSet[ii].second);
+					lastMatch = pos;
+					ZeroInts(match, setCount);
+					}
+				}
+			else
+				{
+				match[ii] = 0;
+				}
+			}
+		}
+	AppendString(ret, aIn.substr(lastMatch));
+
+	delete[] match;
+	return ret;
+	}
+
+void CdlTkUtil::AppendString(string& aTarget, const string& aAppend)
+	{
+	int resSize = aTarget.size() + aAppend.size();
+	if (aTarget.capacity() < resSize)
+		aTarget.reserve(resSize*2);
+	aTarget.append(aAppend);
+	}
+
+static string gCommandLine = "";
+
+string CdlTkUtil::CommandLine()
+	{
+	return gCommandLine;
+	}
+
+void CdlTkUtil::SetCommandLine(int argc, char* argv[])
+	{
+	string tool(argv[0]);
+	tool = tool.substr(tool.find_last_of('\\') + 1);
+	gCommandLine = tool.substr(0, tool.find_last_of('.'));
+	for (int ii=1; ii<argc; ii++)
+		{
+		AppendString(gCommandLine, " ");
+		AppendString(gCommandLine, argv[ii]);
+		}
+	}
+
+//
+// CdlTkUtil::CReplaceSet
+//
+
+void CdlTkUtil::CReplaceSet::Add(const string& aTarget, const string& aWith) 
+	{
+	push_back(make_pair(aTarget, aWith));
+	}
+
+void CdlTkUtil::ReadFile(std::string& aContent, const std::string& aFileName)
+	{
+	ifstream in;
+	OpenInput(in, aFileName);
+	aContent.erase();
+	const int KChars = 1024 + 1;
+	char buf[KChars];
+	while (!in.eof())
+		{
+		in.get(buf,KChars,0);
+		AppendString(aContent, buf);
+		}
+	in.close();
+	}
+
+void CdlTkUtil::WriteFile(const std::string& aContent, const std::string& aFileName)
+	{
+	ofstream out;
+	OpenOutput(out, aFileName);
+	out << aContent;
+	out.close();
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkWriteCdlFile.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,169 @@
+/*
+* 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 "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:
+*
+*/
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include <iomanip>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+
+//
+// CleanupResetPtr
+//
+
+class CleanupResetPtr
+	{
+public:
+	CleanupResetPtr(const CCdlTkInterface*& aPtr) : iPtr(aPtr), iValue(aPtr) {}
+	~CleanupResetPtr() { iPtr = iValue; }
+private:
+	const CCdlTkInterface*& iPtr;
+	const CCdlTkInterface* iValue;
+	};
+
+
+//
+// CCdlTkWriteCdlFile
+//
+
+CCdlTkWriteCdlFile::CCdlTkWriteCdlFile(const CCdlTkInterface& aCdl)
+: iCdl(&aCdl)
+	{
+	}
+
+CCdlTkWriteCdlFile::~CCdlTkWriteCdlFile()
+	{
+	}
+
+void CCdlTkWriteCdlFile::Process()
+	{
+	// this function modifies iCdl, but CleanupResetPtr will restore it at the end (it's also exception safe)
+	CleanupResetPtr resetPtr(iCdl);
+
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(iOut, tempFile);
+	string targetName = iCdl->FileName();
+
+	WriteHeaderComment();
+	int count = 0;
+	while (iCdl)
+		{
+		if (count++)
+			WriteSeparator("Header");
+		WriteHeader();
+		if (!iCdl->Cpp().empty())
+			{
+			WriteSeparator("C++");
+			WriteCpp();
+			}
+		if (!iCdl->DataTypeTranslations().empty())
+			{
+			WriteSeparator("Translation");
+			WriteTranslation();
+			}
+		if (!iCdl->ApiList().empty())
+			{
+			WriteSeparator("API");
+			WriteApi();
+			}
+		iCdl = iCdl->Extension();
+		}
+
+	iOut.close();
+	CdlTkUtil::ExportFile(tempFile, targetName);
+
+	// resetPtr dtor will restore iCdl to original value
+	}
+
+void CCdlTkWriteCdlFile::WriteHeaderComment()
+	{
+	iOut << "// " << iCdl->FileName() << endl;
+	iOut << "// This file was generated by:" << endl;
+	iOut << "// " << CdlTkUtil::CommandLine() << endl;
+	iOut << iCdl->AdditionalComment() << endl;
+	}
+
+void CCdlTkWriteCdlFile::WriteHeader()
+	{
+	const CCdlTkInterfaceHeader& header = iCdl->Header();
+	if (!header.Name().empty())
+		iOut << "Name: " << header.Name() << endl;
+	iOut << "Version: " << header.Version().Major() << "." << header.Version().Minor() << endl;
+	if (header.Uid())
+		iOut << "UID: 0x" << setbase(16) << setw(8) << setfill('0') << header.Uid() << endl;
+	const CCdlTkInterfaceHeader::CFlags& flags = header.Flags();
+	for (int ii=0; ii<flags.Count(); ii++)
+		{
+		if (flags.IsSet(ii))
+			iOut << "Flag: " << flags.FlagName(ii) << endl;
+		}
+	}
+
+void CCdlTkWriteCdlFile::WriteSeparator(const string& aSection)
+	{
+	iOut << endl;
+	iOut << "%% " << aSection << endl;
+	iOut << endl;
+	}
+
+void CCdlTkWriteCdlFile::WriteCpp()
+	{
+	const CCdlTkCpp& cpp = iCdl->Cpp();
+	if(cpp.size())
+		{
+		CCdlTkCpp::const_iterator pStart = cpp.begin();
+		CCdlTkCpp::const_iterator pFinish = cpp.end() ;
+
+		// ignore the first line if it's empty
+		if(pStart->empty())
+			++pStart;
+		// if the last line isn't empty, move the iterator back to the end
+		if(!(--pFinish)->empty())
+			++pFinish;
+
+		for (CCdlTkCpp::const_iterator pLine = pStart; pLine != pFinish; ++pLine)
+			{
+			iOut << *pLine << endl;
+			}
+		}
+	}
+
+void CCdlTkWriteCdlFile::WriteTranslation()
+	{
+	const CCdlTkDataTypeTranslations& translations = iCdl->DataTypeTranslations();
+	for (CCdlTkDataTypeTranslations::const_iterator pTrans = translations.begin(); pTrans != translations.end(); ++pTrans)
+		{
+		if (pTrans->Source() == CCdlTkDataTypeTranslation::EFromCdl)
+			{
+			iOut << pTrans->Type() << " # " << pTrans->Definition() << " # " << pTrans->PointerReference() << endl;
+			}
+		}
+	}
+
+void CCdlTkWriteCdlFile::WriteApi()
+	{
+	const CCdlTkApiList& apiList = iCdl->ApiList();
+	for (CCdlTkApiList::const_iterator pApi = apiList.begin(); pApi != apiList.end(); ++pApi)
+		{
+		CCdlTkApi& api = **pApi;
+		iOut << api.Comment();
+		iOut << api.ReturnType() << " " << api.Name() << api.ParamsTypeAndNameList() << ";" << endl;
+		iOut << endl;
+		}
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkWriteCommonDefs.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,190 @@
+/*
+* 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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+void CCdlTkWriteCommonDefs::ExportCommonDefs(const CCdlTkInterface& aCdl, const std::string& aFileName)
+	{
+	CCdlTkFileCleanup tempFile;
+	ofstream out;
+
+	CdlTkUtil::OpenTempOutput(out, tempFile);
+	CCdlTkWriteCommonDefs commonDefs(aCdl, out, aFileName);
+	commonDefs.ProcessHRH(out);
+	out.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::ToLower(aFileName+"rh"));
+
+	CdlTkUtil::OpenTempOutput(out, tempFile);
+	commonDefs.Process();
+	out.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::ToLower(aFileName));
+	}
+
+CCdlTkWriteCommonDefs::CCdlTkWriteCommonDefs(const CCdlTkInterface& aCdl, ofstream& aStream, const string& aFileName)
+: iCdl(aCdl), iStream(&aStream), iFileName(aFileName)
+	{
+	}
+
+const string KCommonDefsHeader = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of  \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// It contains common definitions for the client and customisation API.\n\
+// It should not be modified manually.\n\
+\n";
+
+const string KHrhContents ="\
+// These constants are defined by the CDL interface: $NAME\n\
+#define _CDL_$NSPACE_KCdlInterfaceUidValue $UID\n\
+\n";
+
+void CCdlTkWriteCommonDefs::ProcessHRH(ofstream& aStream)
+	{
+	iStream = &aStream;
+	string fileName = iFileName + "rh";
+
+	string cdlFileName(CdlTkUtil::ToLower(iCdl.FileName()));
+//	Stream() << CdlTkUtil::Replace("$FILE", cdlFileName, KCommonDefsHeader);
+	Stream() << KCommonDefsHeader;
+	WriteHeaderGuardStart(fileName, Stream());
+
+	const CCdlTkInterfaceHeader& header = iCdl.Header();
+	CdlTkUtil::CReplaceSet headerSet;
+	headerSet.Add("$NAME", header.Name());
+	headerSet.Add("$UID", CdlTkUtil::IntToHexString(header.Uid()));
+	headerSet.Add("$NSPACE", iCdl.NamespaceName());
+	Stream() << CdlTkUtil::MultiReplace(headerSet, KHrhContents);
+
+	WriteHeaderGuardEnd(fileName, Stream());
+	}
+
+const string KInterfaceConstants ="\
+#include \"$THISFILErh\"\n\
+\n\
+// These constants are defined by the CDL interface: $NAME\n\
+_LIT(KCdlName, \"$NAME\");\n\
+const TInt KCdlInterfaceUidValue = _CDL_$NSPACE_KCdlInterfaceUidValue;\n\
+const TUid KCdlInterfaceUid = { KCdlInterfaceUidValue };\n\
+const TInt KCdlInterfaceMajorVersion = $MAJOR;\n\
+const TInt KCdlInterfaceMinorVersion = $MINOR;\n\
+const TUint KCdlInterfaceFlags = $FLAGS;\n\
+\n\
+// These are the API ids used in this interface.\n\
+enum TApiId\n\
+\t{\n";
+
+const string KCdlInterface = "\
+\tE_TApiId_TableSize\n\
+\t};\n\
+\n\
+// This is the CDL interface definition for this interface\n\
+const SCdlInterface KCdlInterface =\n\
+\t{\n\
+\tKCdlCompilerMajorVersion,\n\
+\tKCdlCompilerMinorVersion,\n\
+\tLIT_AS_DESC_PTR(KCdlName),\n\
+\t{ KCdlInterfaceUidValue },\n\
+\tKCdlInterfaceMajorVersion,\n\
+\tKCdlInterfaceMinorVersion,\n\
+\tKCdlInterfaceFlags,\n\
+\tE_TApiId_TableSize\n\
+\t};\n\
+\n\
+// These typedefs define the types for function APIs\n";
+
+void CCdlTkWriteCommonDefs::Process()
+	{
+	string cdlFileName(CdlTkUtil::ToLower(iCdl.FileName()));
+//	Stream() << CdlTkUtil::Replace("$FILE", cdlFileName, KCommonDefsHeader);
+	Stream() << KCommonDefsHeader;
+	WriteHeaderGuardStart(iFileName, Stream());
+	const CCdlTkCpp& cpp = iCdl.Cpp();
+	for (CCdlTkCpp::const_iterator pCpp = cpp.begin(); pCpp != cpp.end(); ++pCpp)
+		Stream() << *pCpp << endl;
+	Stream() << endl;
+	WriteNamespaceStart(iCdl, Stream());
+	const CCdlTkInterfaceHeader& header = iCdl.Header();
+	CdlTkUtil::CReplaceSet headerSet;
+	headerSet.Add("$NAME", header.Name());
+	headerSet.Add("$NSPACE", iCdl.NamespaceName());
+	headerSet.Add("$THISFILE", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iFileName)));
+	headerSet.Add("$MAJOR", CdlTkUtil::IntToString(header.Version().Major()));
+	headerSet.Add("$MINOR", CdlTkUtil::IntToString(header.Version().Minor()));
+	headerSet.Add("$FLAGS", header.Flags().FlagsAsString());
+	Stream() << CdlTkUtil::MultiReplace(headerSet, KInterfaceConstants);
+	WriteApiEnum();
+	Stream() << KCdlInterface;
+	WriteApiTypedefs();
+	Stream() << endl;
+	WriteNamespaceEnd(iCdl, Stream());
+	WriteHeaderGuardEnd(iFileName, Stream());
+	}
+
+void CCdlTkWriteCommonDefs::WriteApiEnum()
+	{
+	const CCdlTkApiList& apiList = iCdl.ApiList();
+	for (CCdlTkApiList::const_iterator pApi = apiList.begin(); pApi != apiList.end(); ++pApi)
+		{
+		Stream() << "\tEApiId_" << (*pApi)->Name() << "," << endl;
+		}
+	}
+
+string CCdlTkWriteCommonDefs::TypedefForApi(const CCdlTkApi& aApi) const
+	{
+	if (aApi.IsFunc())
+		{
+		const CCdlTkFunctionApi& func = aApi.AsFunc();
+		return string("typedef ") + func.ReturnType() + " (" + func.ApiNameAsTypeName() + ")(" + func.ParamTypeList() + ");";
+		}
+	else
+		{
+		return string("// ") + aApi.ReturnType() + " " + aApi.Name() + " \tdoes not need a typedef";
+		}
+	}
+
+void CCdlTkWriteCommonDefs::WriteApiTypedefs()
+	{
+	for (CCdlTkApiList::const_iterator pApi = iCdl.ApiList().begin(); pApi != iCdl.ApiList().end(); ++pApi)
+		Stream() << TypedefForApi(**pApi) << endl;
+	}
+
+std::ofstream& CCdlTkWriteCommonDefs::Stream()
+	{
+	return *iStream;
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkWriteDll.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,443 @@
+/*
+* 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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+CCdlTkWriteDll::CCdlTkWriteDll(const CCdlTkDll& aDll)
+: iDll(aDll)
+	{
+	}
+
+CCdlTkWriteDll::~CCdlTkWriteDll()
+	{
+	}
+
+void CCdlTkWriteDll::Process()
+	{
+	WriteBldInf();
+	WriteMmp();
+	WriteMainCpp();
+	WriteInstanceIdHeader();
+	WriteEcomRss();
+	WriteEcomDetailRss();
+	}
+
+
+//
+// BLD.INF
+//
+
+const string KBldInf = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of  \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This file was generated by:\n\
+// $CMDLINE\n\
+// It lists the makefile for a customisation DLL.\n\
+// It may be modified manually.\n\
+\n\
+PRJ_MMPFILES\n\
+$MMP_NAME\n";
+
+void CCdlTkWriteDll::WriteBldInf() const
+	{
+	string name = CdlTkUtil::OutputPath() + "bld.inf";
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+	stream << 
+		CdlTkUtil::Replace("$CMDLINE", CdlTkUtil::CommandLine(),
+		CdlTkUtil::Replace("$MMP_NAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iDll.Name()+".mmp")), KBldInf));
+	stream.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+
+//
+// MMP
+//
+
+const string KMmp = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This file was generated by:\n\
+// $CMDLINE\n\
+// It contains the project definition for a customisation DLL.\n\
+// It may be modified manually.\n\
+#include <platform_paths.hrh>\n\
+\n\
+target           $UID.dll\n\
+targettype		 PLUGIN\n\
+UID 			 0x10009D8D 0x$UID\n\
+CAPABILITY       CAP_ECOM_PLUGIN\n\
+VENDORID         VID_DEFAULT\n\
+\n\
+SOURCEPATH       .\n\
+userinclude      .\n\
+systeminclude    .\n\
+MW_LAYER_SYSTEMINCLUDE\n\
+\n\
+source           $DLL_SRC_NAME.cpp\n\
+$SOURCE\
+\n\
+library          euser.lib\n\
+$LIBRARIES\
+\n\
+START RESOURCE	 $UID.rss\n\
+TARGET       $UID.rsc\n\
+END\n\
+START RESOURCE   $UID_cdl_detail.rss\n\
+TARGETPATH       resource\\cdl\n\
+END\n\
+\n\
+$EXTRA";
+
+const string KMmpSourceLine = "source           $NAME.cpp\n";
+const string KMmpLibLine = "library          $NAME\n";
+
+void CCdlTkWriteDll::WriteMmp() const
+	{
+	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + iDll.Name() + ".mmp");
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	string source;
+	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
+		CdlTkUtil::AppendString(source, CdlTkUtil::Replace("$NAME", CdlTkUtil::CorrectFilenameCase(*pName), KMmpSourceLine));
+
+	string libraries;
+	for (CCdlTkDll::CLibraries::const_iterator pLib = iDll.Libraries().begin(); pLib != iDll.Libraries().end(); ++pLib)
+		CdlTkUtil::AppendString(libraries, CdlTkUtil::Replace("$NAME", *pLib, KMmpLibLine));
+
+	CdlTkUtil::CReplaceSet mmpSet;
+	mmpSet.Add("$DLL_NAME", iDll.Name());
+	mmpSet.Add("$DLL_SRC_NAME", CdlTkUtil::CorrectFilenameCase(iDll.Name()));
+	mmpSet.Add("$UID", CdlTkUtil::IntToHexString(iDll.Uid()).substr(2));
+	mmpSet.Add("$SOURCE", source);
+	mmpSet.Add("$LIBRARIES", libraries);
+	mmpSet.Add("$EXTRA", iDll.ExtraMmp());
+	mmpSet.Add("$CMDLINE", CdlTkUtil::CommandLine());
+	string mmp = CdlTkUtil::MultiReplace(mmpSet, KMmp);
+
+	stream << mmp;
+	stream.close();
+
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+
+//
+// CPP
+//
+
+const string KMainCpp = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This file was generated by:\n\
+// $CMDLINE\n\
+// This is the main source file for a customisation DLL.\n\
+// It may be modified manually.\n\
+\n\
+$INCLUDES\
+\n\
+CDL_ARRAY_START(SCdlCustomisation, KCdlData)\n\
+\t{\n\
+$INSTANCES\
+\t}\n\
+CDL_ARRAY_END(SCdlCustomisation, KCdlData);\n\
+\n\
+GLREF_D const SCdlMain KCdlMainExport =\n\
+\t{\n\
+\t$MAJOR_VER,\n\
+\t$MINOR_VER,\n\
+\t&KCdlData\n\
+\t};\n\
+\n\
+#include <ecom/ecom.h>\n\
+#include <ecom/implementationproxy.h>\n\
+\n\
+static TAny* MainExport()\n\
+	{\n\
+	return (TAny*)&KCdlMainExport;\n\
+	}\n\
+\n\
+const TImplementationProxy ImplementationTable[] =\n\
+	{\n\
+		{{$DLLUID}, ::MainExport}\n\
+	};\n\
+\n\
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)\n\
+	{\n\
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);\n\
+	return ImplementationTable;\n\
+	}\n\
+\n\
+\n";
+
+string KMainCppInclude = "#include \"$NAME.h\"\n";
+string KMainCppInstance = "\t\tCDL_CUSTOMISATION($CPP_NAME),\n";
+
+void CCdlTkWriteDll::WriteMainCpp() const
+	{
+	string name = CdlTkUtil::CorrectFilenameCase(CdlTkUtil::OutputPath() + iDll.Name() + ".cpp");
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	string includes;
+	string instances;
+	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
+		{
+		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(*pName), KMainCppInclude));
+		CdlTkUtil::AppendString(instances, CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(*pName), KMainCppInstance));
+		}
+
+	stringstream majorVer;
+	majorVer << KCdlCompilerMajorVersion;
+
+	stringstream minorVer;
+	minorVer << KCdlCompilerMinorVersion;
+
+	CdlTkUtil::CReplaceSet cppSet;
+	cppSet.Add("$MAJOR_VER", majorVer.str());
+	cppSet.Add("$MINOR_VER", minorVer.str());
+	cppSet.Add("$INCLUDES", includes);
+	cppSet.Add("$INSTANCES", instances);
+	cppSet.Add("$CMDLINE", CdlTkUtil::CommandLine());
+	cppSet.Add("$DLLUID", CdlTkUtil::IntToHexString(iDll.Uid()));
+	string cpp = CdlTkUtil::MultiReplace(cppSet, KMainCpp);
+
+	stream << cpp;
+	stream.close();
+
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+//
+// Instance ID Header
+//
+
+const string KInstHeaderBody = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// Header file for automatic instance id assignment for $DLL_NAME, generated by:\n\
+// $CMDLINE\n\
+#ifndef $DLL_NAME_INST_IDS\n\
+#define $DLL_NAME_INST_IDS\n\
+\n\
+$IDS\
+\n\
+#endif\n";
+
+const string KInstHeaderId = "#define $ID $NUM\n";
+
+void CCdlTkWriteDll::WriteInstanceIdHeader() const
+	{
+	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + KDllInstHeader);
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	int num = 0;
+	string ids;
+	for (CCdlTkDll::CInstances::const_iterator pName = iDll.Instances().begin(); pName != iDll.Instances().end(); ++pName)
+		{
+		string name = CCdlTkInstance::InstanceNameToDllInstanceName(*pName);
+		string id = CdlTkUtil::Replace("$ID", name, KInstHeaderId);
+		id = CdlTkUtil::Replace("$NUM", CdlTkUtil::IntToHexString(num), id);
+		CdlTkUtil::AppendString(ids, id);
+		num++;
+		}
+
+	CdlTkUtil::CReplaceSet headerSet;
+	headerSet.Add("$DLL_NAME", iDll.Name());
+	headerSet.Add("$IDS", ids);
+	headerSet.Add("$CMDLINE", CdlTkUtil::CommandLine());
+	string header = CdlTkUtil::MultiReplace(headerSet, KInstHeaderBody);
+
+	stream << header;
+	stream.close();
+
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+const string KEComRss = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+#include <ecom/registryinfo.rh>\n\
+#include <cdlecom.hrh>\n\
+\n\
+CDL_ECOM_MAIN_REG_WITH_VERSION(0x$DLLUID, $DLLVER)\n";
+
+void CCdlTkWriteDll::WriteEcomRss() const
+	{
+	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
+	string dllVer = CdlTkUtil::IntToString(iDll.Version());
+	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + dllUid + ".rss");
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	CdlTkUtil::CReplaceSet rssSet;
+	rssSet.Add("$DLLUID", dllUid);
+	rssSet.Add("$DLLVER", dllVer);
+	string rss = CdlTkUtil::MultiReplace(rssSet, KEComRss);
+
+	stream << rss;
+	stream.close();
+
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+const string KEComDetailRss = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+#include <cdlecom.rh>\n\
+#include <cdlecom.hrh>\n\
+\n\
+$INCLUDES\
+\n\
+CDL_ECOM_REG_DETAIL_START\n\
+$INSTANCES\
+CDL_ECOM_REG_DETAIL_END\n";
+
+string KDetailRssInclude = "#include \"$NAME.hrh\"\n";
+string KDetailRssInstance = "\tCDL_ECOM_DETAIL_IMPL($CPP_NAME)\n";
+
+void CCdlTkWriteDll::WriteEcomDetailRss() const
+	{
+	string dllUid = CdlTkUtil::IntToHexString(iDll.Uid()).substr(2);
+	string name = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + dllUid + "_cdl_detail.rss");
+	ofstream stream;
+	CCdlTkFileCleanup tempFile;
+	CdlTkUtil::OpenTempOutput(stream, tempFile);
+
+	string includes;
+	string instances;
+	CCdlTkDll::CInstances::const_iterator begin = iDll.Instances().begin();
+	for (CCdlTkDll::CInstances::const_iterator pName = begin; pName != iDll.Instances().end(); ++pName)
+		{
+		string instance = (pName != begin) ? "," : "";
+		instance += CdlTkUtil::Replace("$CPP_NAME", CdlTkUtil::ToCpp(*pName), KDetailRssInstance);
+		CdlTkUtil::AppendString(instances, instance);
+		CdlTkUtil::AppendString(includes, CdlTkUtil::Replace("$NAME", CdlTkUtil::ToLower(*pName), KDetailRssInclude));
+		}
+
+	CdlTkUtil::CReplaceSet rssSet;
+	rssSet.Add("$INCLUDES", includes);
+	rssSet.Add("$INSTANCES", instances);
+	string rss = CdlTkUtil::MultiReplace(rssSet, KEComDetailRss);
+
+	stream << rss;
+	stream.close();
+
+	CdlTkUtil::ExportFileIfWritable(tempFile, name);
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cdlcompilertoolkit/src/CdlTkWriteInstance.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,341 @@
+/*
+* 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 "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:
+*
+*/
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+#include "CdlCompilerToolkit/CdlTkProcess.h"
+#include "CdlTkPriv.h"
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+using namespace std;
+
+namespace CdlCompilerToolkit {
+
+CCdlTkWriteInstance::CCdlTkWriteInstance(const CCdlTkInstance& aInstance)
+: iInstance(aInstance), iCdl(aInstance.Interface())
+	{
+	}
+
+CCdlTkWriteInstance::~CCdlTkWriteInstance()
+	{
+	}
+
+void CCdlTkWriteInstance::Process()
+	{
+	string implName = CdlTkUtil::ToLower(CdlTkUtil::OutputPath() + CdlTkUtil::StripPath(iInstance.Name()));
+	string headerName(implName + ".h");
+	InitReplace(headerName);
+	ProcessCdl();
+
+	CCdlTkFileCleanup tempFile;
+
+	ofstream hrhStream;
+	CdlTkUtil::OpenTempOutput(hrhStream, tempFile);
+	ProcessInstanceHrh(hrhStream, headerName+"rh");
+	hrhStream.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, headerName+"rh");
+
+	ofstream headerStream;
+	CdlTkUtil::OpenTempOutput(headerStream, tempFile);
+	ProcessInstanceHeader(headerStream, headerName);
+	headerStream.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, headerName);
+
+	ofstream cppStream;
+	CdlTkUtil::OpenTempOutput(cppStream, tempFile);
+	ProcessInstance(cppStream, headerName);
+	cppStream.close();
+	CdlTkUtil::ExportFileIfWritable(tempFile, CdlTkUtil::CorrectFilenameCase(implName + ".cpp"));
+	}
+
+void CCdlTkWriteInstance::InitReplace(const std::string& aHeaderName)
+	{
+	iReplace.clear();
+	iReplace.Add("$INSTNAME", iInstance.Name());
+	iReplace.Add("$CDLNAME", CdlTkUtil::StripPath(iCdl.FileName()));
+	iReplace.Add("$CDLINCNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(iCdl.FileName())));
+	iReplace.Add("$HEADERNAME", CdlTkUtil::ToLower(CdlTkUtil::StripPath(aHeaderName)));
+	iReplace.Add("$EXTRA", iInstance.ExtraCpp());
+	iReplace.Add("$INSTNS", CdlTkUtil::ToCpp(iInstance.Name()));
+	iReplace.Add("$CDLNS", iCdl.NamespaceName());
+	iReplace.Add("$CDLGUARD", HeaderGuardName(iCdl.FileName() + ".custom.h"));
+	iReplace.Add("$INSTGUARD", HeaderGuardName(aHeaderName));
+	iReplace.Add("$CMDLINE", CdlTkUtil::CommandLine());
+	if (iInstance.Id() == KCdlTkGetInstanceIdFromHostDll)
+		{
+		iReplace.Add("$INSTID", iInstance.DllInstanceName());
+		iReplace.Add("$DLLINSTHEADER", "#include \"" + KDllInstHeader + "\"\n");
+		}
+	else
+		{
+		iReplace.Add("$INSTID", CdlTkUtil::IntToString(iInstance.Id()));
+		iReplace.Add("$DLLINSTHEADER", "");
+		}
+	}
+
+void CCdlTkWriteInstance::ProcessCdl() const
+	{
+	AssertInterfaceNotExtended(iCdl);
+
+	string baseName = CdlBaseNameAndPath(iCdl);
+
+	string commonHeaderName(baseName + KCommonHeader);
+	CCdlTkWriteCommonDefs::ExportCommonDefs(iCdl, commonHeaderName);
+
+	CCdlTkFileCleanup tempFile;
+	ofstream out;
+	CdlTkUtil::OpenTempOutput(out, tempFile);
+	string customHeaderName(baseName + ".custom.h");
+	ProcessInstanceApi(out, customHeaderName);
+	out.close();
+	CdlTkUtil::ExportFile(tempFile, customHeaderName);
+	}
+
+
+const string KInstanceApiStart = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This file was generated from $CDLNAME.\n\
+// It contains the customisation API.\n\
+// It should not be modified manually.\n\
+\n\
+#ifndef $CDLGUARD\n\
+#define $CDLGUARD\n\
+\n\
+#include <cdlengdef.h>\n\
+#include \"$CDLINCNAME.common.h\"\n\
+\n\
+namespace $CDLNS\n\
+{\n\
+\n\
+// This structure defines the interface to a customisation instance.\n\
+// A customisation instance must supply an instance of this structure, with the pointer\n\
+// members either being NULL, or pointing at functions or data of the correct type.\n\
+\n\
+#ifdef __WINS__\n\
+struct SCdlImpl0\n\
+#else\n\
+struct SCdlImpl\n\
+#endif\n\
+\t{\n";
+
+const string KInstanceApiEnd = "\
+\t};\n\
+#ifdef __WINS__\n\
+struct SCdlImpl\n\
+\t{\n\
+\tSCdlImpl0 i0;\n\
+$SUBSTRUCTS\
+\t};\n\
+#endif\n\
+\n\
+} // end of namespace $CDLNS\n\
+#endif // $CDLGUARD\n";
+
+const string KSubStructDecl = "\
+#ifdef __WINS__\n\
+\t};\n\
+\n\
+struct SCdlImpl$NUM\n\
+\t{\n\
+#endif\n";
+
+const string KSubStructUse = "\tSCdlImpl$NUM i$NUM;\n";
+
+const int KMsvcStructSplit = 1000;
+
+void CCdlTkWriteInstance::ProcessInstanceApi(ofstream& aStream, const string& aFileName) const
+	{
+	string subStructs;
+	int count=0;
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceApiStart);
+	for (CCdlTkApiList::const_iterator pApi = iCdl.ApiList().begin(); pApi != iCdl.ApiList().end(); ++pApi)
+		{
+		aStream << "\t" << (*pApi)->PointerType() << " " << (*pApi)->Name() << ";" << endl;
+		count++;
+		if ((count%KMsvcStructSplit) == 0)
+			{
+			string num = CdlTkUtil::IntToString(count/KMsvcStructSplit);
+			aStream << CdlTkUtil::Replace("$NUM", num, KSubStructDecl);
+			CdlTkUtil::AppendString(subStructs, CdlTkUtil::Replace("$NUM", num, KSubStructUse));
+			}
+		}
+	string end = CdlTkUtil::Replace("$SUBSTRUCTS", subStructs, KInstanceApiEnd);
+	aStream << CdlTkUtil::MultiReplace(iReplace, end);
+	}
+
+
+const string KInstanceCppStart = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// $INSTNAME generated by\n\
+// $CMDLINE\n\
+// This customisation implements the interface defined in $CDLNAME\n\
+\n\
+#include \"$HEADERNAME\"\n\
+$EXTRA\n\
+namespace $INSTNS\n\
+{\n\
+\n";
+
+const string KInstanceCppMid = "\
+\n\
+const $CDLNS::SCdlImpl KCdlImpl = \n\
+\t{\n";
+
+const string KInstanceCppEnd = "\
+\t};\n\
+\n\
+} // end of namespace $INSTNS\n";
+
+void CCdlTkWriteInstance::ProcessInstance(ofstream& aStream, const string& aHeaderName) const
+	{
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceCppStart);
+	
+	const CCdlTkImplementations& impl = iInstance.Impl();
+	CCdlTkImplementations::const_iterator pImpl;
+	// write the definitions
+	for (pImpl = impl.begin(); pImpl != impl.end(); ++pImpl)
+		{
+		const string& defn = (*pImpl)->Definition();
+		if (defn.size())
+			{
+			aStream << defn << endl;
+			aStream << endl;
+			}
+		}
+
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceCppMid);
+
+	// write the pointers
+	for (pImpl = impl.begin(); pImpl != impl.end(); ++pImpl)
+		aStream << "\t" << (*pImpl)->PointerReference() << "," << endl;
+
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceCppEnd);
+	}
+
+
+const string KInstanceHeader = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This header file contains the customisation implementation identity for $INSTNAME\n\
+// It was generated by:\n\
+// $CMDLINE\n\
+// This file may be manually modified.\n\
+\n\
+#ifndef $INSTGUARD\n\
+#define $INSTGUARD\n\
+#include \"$CDLINCNAME.custom.h\"\n\
+#include \"$HEADERNAMErh\"\n\
+\n\
+namespace $INSTNS\n\
+{\n\
+\n\
+const TInt KCdlInstanceId = _CDL_$INSTNS_KCdlInstanceId;\n\
+using $CDLNS::KCdlInterface;\n\
+using $CDLNS::KCdlInterfaceUidValue;\n\
+GLREF_D const $CDLNS::SCdlImpl KCdlImpl;\n\
+\n\
+} // end of namespace $INSTNS\n\
+#endif // $INSTGUARD\n";
+
+void CCdlTkWriteInstance::ProcessInstanceHeader(ofstream& aStream, const string& aFileName) const
+	{
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceHeader);
+	}
+
+
+const string KInstanceHrh = "\
+/*\n\
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\n\
+* All rights reserved.\n\
+* This component and the accompanying materials are made available\n\
+* under the terms of \"Eclipse Public License v1.0\"\n\
+* which accompanies this distribution, and is available\n\
+* at the URL \"http://www.eclipse.org/legal/epl-v10.html\".\n\
+*\n\
+* Initial Contributors:\n\
+* Nokia Corporation - initial contribution.\n\
+*\n\
+* Contributors:\n\
+*\n\
+* Description:\n\
+*\n\
+*/\n\n\
+// This header file contains the customisation implementation identity for $INSTNAME\n\
+// It was generated by:\n\
+// $CMDLINE\n\
+// This file may be manually modified.\n\
+\n\
+#ifndef $INSTGUARDRH\n\
+#define $INSTGUARDRH\n\
+#include \"$CDLINCNAME.common.hrh\"\n\
+$DLLINSTHEADER\
+\n\
+#define _CDL_$INSTNS_KCdlInstanceInterfaceUidValue _CDL_$CDLNS_KCdlInterfaceUidValue\n\
+#define _CDL_$INSTNS_KCdlInstanceId $INSTID\n\
+\n\
+#endif // $INSTGUARDRH\n";
+
+void CCdlTkWriteInstance::ProcessInstanceHrh(ofstream& aStream, const string& aFileName) const
+	{
+	aStream << CdlTkUtil::MultiReplace(iReplace, KInstanceHrh);
+	}
+
+}	// end of namespace CdlCompilerToolkit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/group/Color.mmp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET                  series60color.exe
+TARGETTYPE              EXE
+
+USERINCLUDE             .
+USERINCLUDE             ../inc
+USERINCLUDE			../../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+
+SOURCEPATH              ../src
+source                  Main.cpp
+source                  Color.cpp
+source                  NokiaBlue.cpp
+source                  NokiaGreen.cpp
+source                  NokiaPurple.cpp
+source                  NokiaGrey.cpp
+source                  SchemeRed.cpp
+source                  SchemePink.cpp
+source                  SchemeOrange.cpp
+source                  Palette1.cpp
+source                  Palette2.cpp
+source                  Palette3.cpp
+source                  Palette4.cpp
+source                  Palette5.cpp
+source                  Palette6.cpp
+source                  Palette7.cpp
+source                  Palette8.cpp
+source                  Palette9.cpp
+source                  Palette10.cpp
+source                  Palette11.cpp
+source                  Palette12.cpp
+source                  Palette13.cpp
+source                  Strings.cpp
+source                  Rgb.cpp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  Build information file for project Color
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+CWTOOLS TOOLS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+#if defined(TOOLS) || defined(CWTOOLS)
+../group/Color.mmp
+gnumakefile ../group/convcolor.mk
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/group/convcolor.mk	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,44 @@
+#
+# 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 "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:
+#
+# For template extension makefiles, must include the following lines when using the EPOCROOT
+# To ensure that EPOCROOT always ends with a forward slash. 
+TMPROOT:=$(subst \,/,$(EPOCROOT))
+EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
+
+do_nothing :
+	@echo do_nothing
+
+MAKMAKE : do_nothing
+
+BLD :
+	@$(EPOCROOT)EPOC32/TOOLS/series60color.exe
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES : ;
+
+FINAL : do_nothing
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/inc/Color.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#ifndef COLOR_H
+#define COLOR_H
+
+#include "RGB.H"
+
+class TColorScheme
+	{
+public:
+	enum 
+		{
+		StandardGrayBase = 216,
+		SchemeSpecificColorBase = 226
+		};
+
+public:
+	virtual TRgb Color(int aIndex) const = 0;
+	};
+
+
+class Color
+	{
+public:
+	enum TSchemeId
+		{
+		ENokiaBlue,
+		ENokiaGreen,
+		ENokiaPurple,
+        ENokiaGrey,
+        ESchemeRed,
+        ESchemePink,
+        ESchemeOrange,
+        EPalette1,
+        EPalette2,
+        EPalette3,
+        EPalette4,
+        EPalette5,
+        EPalette6,
+        EPalette7,
+        EPalette8,
+        EPalette9,
+        EPalette10,
+        EPalette11,
+        EPalette12,
+        EPalette13
+		};
+
+public:
+	static TColorScheme* CreateColorSchemeL(TSchemeId aScheme);
+	static void CreateBmConvPalette(TSchemeId aScheme, char* aFilename);
+	static void CreatePaletteTable(TSchemeId aScheme, char* aPaletteName);
+	static void EquivalenceTest();
+private:
+	typedef int TEquivalenceList[256];
+	static void MakeEqivalenceList(TSchemeId aScheme, TEquivalenceList& aList);
+	};
+
+
+#endif
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/inc/ColorImp.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#ifndef COLORIMP_H
+#define COLORIMP_H
+
+#include "Color.h"
+
+const int KStandardGray[10] = {0xee, 0xdd, 0xbb, 0xaa, 0x88, 0x77, 0x55, 0x44, 0x22, 0x11};
+const int KColorCubeMap[6] = {0xff, 0xcc, 0x99, 0x66, 0x33, 0x00};
+
+class TNokiaBlue : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TNokiaGreen : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TNokiaPurple : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TNokiaGrey : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TSchemeRed : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TSchemePink : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TSchemeOrange : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette1 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette2 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette3 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette4 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette5 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette6 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette7 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette8 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette9 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette10 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette11 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette12 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+class TPalette13 : public TColorScheme
+	{
+public:
+	TRgb Color(int aIndex) const;
+	};
+
+#endif
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/inc/RGB.H	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+// 
+//
+// Copyright (c) 1997-2000 Symbian Ltd.  All rights reserved.
+//
+
+class TRgb
+	{
+public:
+	TRgb();
+	TRgb(long unsigned int val);
+	TRgb(int aRed,int aGreen,int aBlue);
+	TRgb &operator=(const TRgb& aColor);
+	int operator==(const TRgb& aColor);
+	int Difference(const TRgb& col) const;
+public:
+	unsigned char iRed;
+	unsigned char iGreen;
+	unsigned char iBlue;
+	unsigned char iSpare;
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Color.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#pragma warning (disable:4710)
+#include "ColorImp.h"
+#include <fstream.h>
+#include <stdio.h>
+#include <iostream.h>
+
+extern const char* gIntroText;
+extern const char* gMiddleText;
+extern const char* gEndText;
+
+TColorScheme* Color::CreateColorSchemeL(TSchemeId aScheme)
+	{
+	switch (aScheme)
+		{
+		case ENokiaBlue:
+			return new TNokiaBlue;
+			break;
+		case ENokiaGreen:
+			return new TNokiaGreen;
+			break;
+		case ENokiaPurple:
+			return new TNokiaPurple;
+			break;
+        case ENokiaGrey:
+			return new TNokiaGrey;
+			break;
+		case ESchemeRed:
+			return new TSchemeRed;
+			break;
+		case ESchemePink:
+			return new TSchemePink;
+			break;
+		case ESchemeOrange:
+			return new TSchemeOrange;
+			break;
+        case EPalette1:
+			return new TPalette1;
+			break;
+        case EPalette2:
+			return new TPalette2;
+			break;
+        case EPalette3:
+			return new TPalette3;
+			break;
+        case EPalette4:
+			return new TPalette4;
+			break;
+        case EPalette5:
+			return new TPalette5;
+			break;
+        case EPalette6:
+			return new TPalette6;
+			break;
+        case EPalette7:
+			return new TPalette7;
+			break;
+        case EPalette8:
+			return new TPalette8;
+			break;
+        case EPalette9:
+			return new TPalette9;
+			break;
+        case EPalette10:
+			return new TPalette10;
+			break;
+        case EPalette11:
+			return new TPalette11;
+			break;
+        case EPalette12:
+			return new TPalette12;
+			break;
+        case EPalette13:
+			return new TPalette13;
+			break;
+		}
+	return 0;
+	}
+
+void Color::CreateBmConvPalette(TSchemeId aScheme, char* aFilename)
+	{
+	cout << "Creating " << aFilename << endl;
+
+	TColorScheme* scheme = CreateColorSchemeL(aScheme);
+
+	ofstream out(aFilename);
+	if (out.is_open())
+		{
+		for (int i=0; i<256; i++)
+			{
+			char str[32];
+			sprintf(str, "0x%08X\n", scheme->Color(i));
+			out << str;
+			}
+		}
+	out.close();
+
+	delete scheme;
+	}
+
+void Color::CreatePaletteTable(TSchemeId aScheme, char* aPaletteName)
+	{
+	char buf[1024];
+	sprintf(buf, "\\s60\\palette\\inc\\%s.h", aPaletteName);
+	cout << "Creating " << buf << endl;
+
+	TColorScheme* scheme = CreateColorSchemeL(aScheme);
+
+	ofstream out(buf);
+	if (out.is_open())
+		{
+		sprintf(buf, gIntroText, aPaletteName, aPaletteName, aPaletteName, aPaletteName, aPaletteName);
+		out << buf;
+
+		int i;
+		for (i=0; i<256; i++)
+			{
+			char str[32];
+			sprintf(str, "\t0x%08X", scheme->Color(i));
+			out << str;
+			if (i == 255)
+				out << endl;
+			else
+				out << "," << endl;
+			}
+
+		out << gMiddleText;
+
+		for (i=0; i<4096; i++)
+			{
+			TRgb color = TRgb((i & 0x00f) * 17,((i & 0x0f0) * 17)>>4,((i & 0xf00) * 17)>>8);
+
+			int nearest = 0;
+			int distance = scheme->Color(0).Difference(color);
+
+			for (int paletteIndex = 1; paletteIndex < 256; paletteIndex++)
+				{
+				TRgb paletteColor = scheme->Color(paletteIndex);
+
+				if (paletteColor == color)
+					{
+					nearest = paletteIndex;
+					break;
+					}
+
+				int paletteDistance = paletteColor.Difference(color);
+				if (paletteDistance < distance)
+					{
+					nearest = paletteIndex;
+					distance = paletteDistance;
+					}
+				}
+
+			if (i%16 == 0)
+				out << "\t";
+			else
+				out << " ";
+
+			char str[32];
+			sprintf(str, "0x%02X", nearest);
+			out << str;
+
+			if (i<4095)
+				out << ",";
+			if (i%16 == 15)
+				out << endl;
+			}
+
+		out << gEndText;
+		}
+	out.close();
+
+	delete scheme;
+	}
+
+void Color::EquivalenceTest()
+	{
+	const int KNumSchemes = 6;
+
+	TEquivalenceList list[KNumSchemes];
+	for (int s=0; s<KNumSchemes; s++)
+		MakeEqivalenceList((Color::TSchemeId)s, list[s]);
+
+	for (int i=0; i<256; i++)
+		{
+		for (int s=0; s<KNumSchemes; s++)
+			{
+			if (list[0][i] != list[s][i])
+				{
+				cout << "Palette equivalence failure at " << s << "[" << i << "]";
+				cout << " " << list[0][i] << "!=" << list[s][i];
+				cout << endl;
+				}
+			}
+		}
+	}
+
+void Color::MakeEqivalenceList(TSchemeId aScheme, TEquivalenceList& aList)
+	{
+	TColorScheme* scheme = CreateColorSchemeL(aScheme);
+
+	for (int i=0; i<256; i++)
+		{
+		for (int j=0; j<256; j++)
+			{
+			if (scheme->Color(i) == scheme->Color(j))
+				{
+				aList[i] = j;
+				break;
+				}
+			}
+		}
+
+	delete scheme;
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Main.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "Color.h"
+
+int main()
+	{
+	Color::EquivalenceTest();
+
+	Color::CreateBmConvPalette(Color::ENokiaBlue, "\\epoc32\\include\\NokiaBlue.pal");
+
+	Color::CreatePaletteTable(Color::ENokiaBlue, "NokiaBlue");
+	Color::CreatePaletteTable(Color::ENokiaGreen, "NokiaGreen");
+	Color::CreatePaletteTable(Color::ENokiaPurple, "NokiaPurple");
+    Color::CreatePaletteTable(Color::ENokiaGrey, "NokiaGrey");
+	Color::CreatePaletteTable(Color::ESchemeRed, "SchemeRed");
+	Color::CreatePaletteTable(Color::ESchemePink, "SchemePink");
+	Color::CreatePaletteTable(Color::ESchemeOrange, "SchemeOrange");
+    Color::CreatePaletteTable(Color::EPalette1, "Palette1");
+    Color::CreatePaletteTable(Color::EPalette2, "Palette2");
+    Color::CreatePaletteTable(Color::EPalette3, "Palette3");
+    Color::CreatePaletteTable(Color::EPalette4, "Palette4");
+    Color::CreatePaletteTable(Color::EPalette5, "Palette5");
+    Color::CreatePaletteTable(Color::EPalette6, "Palette6");
+    Color::CreatePaletteTable(Color::EPalette7, "Palette7");
+    Color::CreatePaletteTable(Color::EPalette8, "Palette8");
+    Color::CreatePaletteTable(Color::EPalette9, "Palette9");
+    Color::CreatePaletteTable(Color::EPalette10, "Palette10");
+    Color::CreatePaletteTable(Color::EPalette11, "Palette11");
+    Color::CreatePaletteTable(Color::EPalette12, "Palette12");
+    Color::CreatePaletteTable(Color::EPalette13, "Palette13");
+
+	return 0;
+	}
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/NokiaBlue.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KNokiaBlue[30] =
+	{
+    0x00FFEEEE,
+    0x00FFDBD6,
+    0x00FFC2BD,
+    0x00FFAA9C,
+    0x00FF8E7B,
+    0x00FF6D5A,
+    0x00FF4D3A,
+    0x00FF2D10,
+    0x00EF1800,
+    0x00C51400,
+    0x00A51000,
+    0x00840C00,
+    0x00630C00,
+    0x00420800,
+    0x00290400,
+    0x00080000,
+    0x00FEFEFE,
+    0x00FF513A,
+    0x00FFAEA5,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+
+TRgb TNokiaBlue::Color(int aIndex) const
+	{
+	// Color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KNokiaBlue[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/NokiaGreen.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KNokiaGreen[30] =
+	{
+    0x00EFFFEF,
+    0x00DEFFD6,
+    0x00C5FFBD,
+    0x00A5FF9C,
+    0x008CFF7B,
+    0x006BFF5A,
+    0x004AFF3A,
+    0x0029FF10,
+    0x0010EB00,
+    0x0010C600,
+    0x0010A200,
+    0x00088200,
+    0x00086100,
+    0x00084100,
+    0x00002800,
+    0x00001000,
+    0x00FEFEFE,
+    0x0063CA00,
+    0x00CEFFCE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TNokiaGreen::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KNokiaGreen[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/NokiaGrey.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KNokiaGrey[30] =
+	{
+    0x00F7F7F7,
+    0x00EFEBEF,
+    0x00DEDFDE,
+    0x00CECECE,
+    0x00BDBEBD,
+    0x00ADAEAD,
+    0x009C9A9C,
+    0x008C8A8C,
+    0x00737573,
+    0x00636563,
+    0x00525152,
+    0x00424142,
+    0x00313131,
+    0x00212021,
+    0x00101410,
+    0x00080808,
+    0x00FEFEFE,
+    0x009C9E9C,
+    0x00CED2CE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+
+TRgb TNokiaGrey::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KNokiaGrey[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/NokiaPurple.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KNokiaPurple[30] =
+	{
+    0x00FFEBFF,
+    0x00FFD7FF,
+    0x00F7BEFF,
+    0x00F79EFF,
+    0x00F77DFF,
+    0x00EF59FF,
+    0x00EF39FF,
+    0x00E614FF,
+    0x00D600EF,
+    0x00B500C5,
+    0x009400A5,
+    0x00730084,
+    0x005A0063,
+    0x003A0042,
+    0x00210029,
+    0x00100019,
+    0x00FEFEFE,
+    0x00CE35CE,
+    0x00FFCAFF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+
+TRgb TNokiaPurple::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KNokiaPurple[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette1.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette1[30] =
+	{
+    0x00EFEFFF,
+    0x00D6D7FF,
+    0x00BDBEFF,
+    0x009C9EFF,
+    0x007B7DFF,
+    0x005A59FF,
+    0x003A39FF,
+    0x001014FF,
+    0x000000EF,
+    0x000000C5,
+    0x000000A5,
+    0x00000084,
+    0x00000063,
+    0x00000042,
+    0x00000029,
+    0x00000010,
+    0x00FEFEFE,
+    0x003135FF,
+    0x00CECAFF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette1::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette1[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette10.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette10[30] =
+	{
+    0x00FFEFF7,
+    0x00FFD7EF,
+    0x00FFBEDE,
+    0x00FF9ECE,
+    0x00FF7DBD,
+    0x00FF59AD,
+    0x00FF399C,
+    0x00FF148C,
+    0x00EF0073,
+    0x00C50063,
+    0x00A50052,
+    0x00840042,
+    0x00630031,
+    0x00420021,
+    0x00290010,
+    0x00100008,
+    0x00FEFEFE,
+    0x00FF3D9C,
+    0x00FF9ACE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette10::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette10[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette11.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette11[30] =
+	{
+    0x00FFEFFF,
+    0x00FFD7F7,
+    0x00FFBEEF,
+    0x00FF9EE6,
+    0x00FF7DDE,
+    0x00FF59D6,
+    0x00FF39CE,
+    0x00FF14C5,
+    0x00EF00B5,
+    0x00C50094,
+    0x00A5007B,
+    0x00840063,
+    0x0063004A,
+    0x00420031,
+    0x00290021,
+    0x00100010,
+    0x00FEFEFE,
+    0x00FF5DD6,
+    0x00FFC2EF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette11::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette11[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette12.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette12[30] =
+	{
+    0x00F7EFFF,
+    0x00EFD7FF,
+    0x00E6BEFF,
+    0x00D69EFF,
+    0x00CE7DFF,
+    0x00BD59FF,
+    0x00AD39FF,
+    0x00A514FF,
+    0x008C00EF,
+    0x007300C5,
+    0x006300A5,
+    0x004A0084,
+    0x003A0063,
+    0x00290042,
+    0x00190029,
+    0x00080010,
+    0x00FEFEFE,
+    0x00AD3DFF,
+    0x00D6A2FF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette12::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette12[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette13.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette13[30] =
+	{
+    0x00F7EBFF,
+    0x00E6D7FF,
+    0x00D6BEFF,
+    0x00BD9EFF,
+    0x00A57DFF,
+    0x009459FF,
+    0x007339FF,
+    0x006314FF,
+    0x004A00EF,
+    0x004200C5,
+    0x003100A5,
+    0x00290084,
+    0x00210063,
+    0x00190042,
+    0x00100029,
+    0x00080019,
+    0x00FEFEFE,
+    0x007B41FF,
+    0x00BDA2FF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette13::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette13[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette2.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette2[30] =
+	{
+    0x00EFF7FF,
+    0x00D6EFFF,
+    0x00BDE3FF,
+    0x009CD7FF,
+    0x007BCAFF,
+    0x005ABAFF,
+    0x003AAAFF,
+    0x00109EFF,
+    0x00008AEF,
+    0x000071C5,
+    0x00005DA5,
+    0x00004984,
+    0x00003963,
+    0x00002442,
+    0x00001829,
+    0x00000810,
+    0x00FEFEFE,
+    0x00009AFF,
+    0x0063CAFF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette2::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette2[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette3.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette3[30] =
+	{
+    0x00EDFFFF,
+    0x00D6FBFF,
+    0x00BDF7FF,
+    0x009CF3FF,
+    0x007BEFFF,
+    0x005AEBFF,
+    0x003AE7FF,
+    0x0010E3FF,
+    0x0000CEEF,
+    0x0000AEC5,
+    0x00008EA5,
+    0x00007184,
+    0x00005563,
+    0x00003942,
+    0x00002429,
+    0x00001010,
+    0x00FEFEFE,
+    0x0000D2EF,
+    0x00A2F4FF,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette3::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette3[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette4.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette4[30] =
+	{
+    0x00EFFFFF,
+    0x00D6FFF7,
+    0x00BDFFEF,
+    0x009CFFE6,
+    0x007BFFE6,
+    0x005AFFDE,
+    0x003AFFD6,
+    0x0010FFCE,
+    0x0000EBB5,
+    0x0000C69C,
+    0x0000A27B,
+    0x00008263,
+    0x0000614A,
+    0x00004131,
+    0x00002821,
+    0x00001410,
+    0x00FEFEFE,
+    0x0031CA9C,
+    0x0063FFCE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette4::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette4[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette5.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette5[30] =
+	{
+    0x00EFFFF7,
+    0x00D6FFEF,
+    0x00BDFFDE,
+    0x009CFFCE,
+    0x007BFFBD,
+    0x005AFFAD,
+    0x003AFF9C,
+    0x0010FF8C,
+    0x0000EB73,
+    0x0000C663,
+    0x0000A252,
+    0x00008242,
+    0x00006131,
+    0x00004121,
+    0x00002810,
+    0x00001008,
+    0x00FEFEFE,
+    0x0000CA63,
+    0x0063FFAD,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette5::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette5[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette6.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette6[30] =
+	{
+    0x00F7FFEF,
+    0x00EFFFD6,
+    0x00E6FFBD,
+    0x00DEFF9C,
+    0x00D6FF7B,
+    0x00C5FF5A,
+    0x00BDFF3A,
+    0x00ADFF10,
+    0x009CEB00,
+    0x0084C600,
+    0x006BA200,
+    0x00528200,
+    0x00426100,
+    0x00294100,
+    0x00192800,
+    0x00081000,
+    0x00FEFEFE,
+    0x009CCA31,
+    0x00FFFFCE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette6::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette6[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette7.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette7[30] =
+	{
+    0x00FFFBEF,
+    0x00FFF3D6,
+    0x00FFEBBD,
+    0x00FFE39C,
+    0x00FFD77B,
+    0x00FFCA5A,
+    0x00FFC23A,
+    0x00FFB610,
+    0x00EFA200,
+    0x00C58A00,
+    0x00A57100,
+    0x00845900,
+    0x00634100,
+    0x00422D00,
+    0x00291C00,
+    0x00100C00,
+    0x00FEFEFE,
+    0x00FFC242,
+    0x00FFE3A5,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette7::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette7[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette8.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette8[30] =
+	{
+    0x00FFF3EF,
+    0x00FFE7D6,
+    0x00FFD7BD,
+    0x00FFC69C,
+    0x00FFB27B,
+    0x00FF9E5A,
+    0x00FF8A3A,
+    0x00FF7110,
+    0x00EF6100,
+    0x00C55100,
+    0x00A54100,
+    0x00843500,
+    0x00632800,
+    0x00421C00,
+    0x00291000,
+    0x00100800,
+    0x00FEFEFE,
+    0x00FF8E3A,
+    0x00FFCAA5,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette8::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette8[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/Palette9.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KPalette9[30] =
+	{
+    0x00FFEFEF,
+    0x00FFD7DE,
+    0x00FFBECE,
+    0x00FF9EB5,
+    0x00FF7D9C,
+    0x00FF597B,
+    0x00FF3963,
+    0x00FF1442,
+    0x00EF0031,
+    0x00C50029,
+    0x00A50021,
+    0x00840019,
+    0x00630010,
+    0x00420010,
+    0x00290008,
+    0x00100000,
+    0x00FEFEFE,
+    0x00FF659C,
+    0x00FFCACE,
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+    0x00FEFEFE, // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,  // nokia brand color green 253
+    0x00CC3300,  // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+TRgb TPalette9::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KPalette9[aIndex - SchemeSpecificColorBase]);
+		}
+	};
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/RGB.CPP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+// 
+//
+// Copyright (c) 1997-2000 Symbian Ltd.  All rights reserved.
+//
+
+#pragma warning (disable:4514)
+#include "RGB.H"
+#include <math.h>
+#include <stdlib.h>
+
+TRgb::TRgb()
+	: iRed(255),iGreen(255),iBlue(255),iSpare(0)
+	{}
+
+TRgb::TRgb(long unsigned int val)
+	: iRed((unsigned char)(val&0xff)),iGreen((unsigned char)((val>>8)&0xff)),iBlue((unsigned char)((val>>16)&0xff)),iSpare(0)
+	{}
+
+TRgb::TRgb(int r,int g,int b)
+	: iRed((unsigned char)r),iGreen((unsigned char)g),iBlue((unsigned char)b),iSpare(0)
+	{}
+
+TRgb &TRgb::operator=(const TRgb &col)
+	{
+	iRed=col.iRed;
+	iGreen=col.iGreen;
+	iBlue=col.iBlue;
+	return(*this);
+	}
+
+int TRgb::operator==(const TRgb &col)
+	{
+	return(iRed==col.iRed && iGreen==col.iGreen && iBlue==col.iBlue);
+	}
+
+int TRgb::Difference(const TRgb& col) const
+	{
+	return abs(iRed-col.iRed) + abs(iGreen-col.iGreen) + abs(iBlue-col.iBlue);
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/SchemeOrange.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KSchemeOrange[30] =
+	{
+    0x00EECCFF,     // 226
+    0x0099BBFF,
+    0x0088AAFF,
+    0x0077AAFF,
+    0x0055AAFF,
+    0x0044AAFF,
+    0x0033AAFF,
+    0x0011AAFF,
+    0x0000AAFF,
+    0x002299FF,
+    0x001166FF,
+    0x000066EE,
+    0x001166EE,
+    0x001166DD,
+    0x001166CC,
+    0x001166BB,     // 241
+    0x00FEFEFE,     // undefined
+    0x00001100,
+    0x0011BBFF,  
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x0000EEFF,     // coding yellow
+    0x000000DD,     // coding red
+    0x00FF7700,     // coding blue
+    0x0000EE00,     // coding green
+    0x00339900,     // nokia brand color green 253
+    0x00CC3300,     // nokia brand color blue 254
+    0x00DD00DD      // mask pink
+	};
+
+
+TRgb TSchemeOrange::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KSchemeOrange[aIndex - SchemeSpecificColorBase]);
+		}
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/SchemePink.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KSchemePink[30] =
+	{
+    0x00EFEFEF,     // 226
+    0x00E6E7E6,
+    0x00DEDBDE,
+    0x00D6D2D6,
+    0x00BDC2BD,
+    0x00B5B2B5,
+    0x00949294,
+    0x00848284,
+    0x00737173,
+    0x005A595A,
+    0x004A4D4A,
+    0x00636163,     // NOTE! Conflicts with battery, signal and scroll indicator colors
+    0x003A3D3A,
+    0x00292D29,
+    0x00211C21,
+    0x00101010,     // 241
+    0x00FEFEFE,     // undefined
+    0x00949694,     
+    0x00C5C6C5,     
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,     // nokia brand color green 253
+    0x00CC3300,     // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+
+TRgb TSchemePink::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KSchemePink[aIndex - SchemeSpecificColorBase]);
+		}
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/SchemeRed.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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: 
+*       
+*
+*/
+
+
+#include "ColorImp.h"
+
+const TRgb KSchemeRed[30] =
+	{
+    0x00CCDDFF,
+    0x00BBCCFF,
+    0x00AABBFF,
+    0x0099AAFF,
+    0x008899FF,
+    0x007788FF,
+    0x006677FF,
+    0x005566EE,
+    0x004455EE,
+    0x003344EE,
+    0x002233EE,
+    0x000000EE,
+    0x000000BB,
+    0x000000AA,
+    0x00000088,
+    0x00000077,     // 241
+    0x00FEFEFE,     // undefined
+    0x005566FF,  
+    0x00BBCCCC,  
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+    0x00FEFEFE,     // undefined
+	0x0000EEFF,		// coding yellow
+	0x000000DD,		// coding red
+	0x00FF7700,		// coding blue
+	0x0000EE00,		// coding green
+    0x00339900,     // nokia brand color green 253
+    0x00CC3300,     // nokia brand color blue 254
+	0x00DD00DD		// mask pink
+	};
+
+
+TRgb TSchemeRed::Color(int aIndex) const
+	{
+	// color rotation for palette
+	if (aIndex == 0)
+		return TRgb(0x00000000);
+	else if (aIndex == 0xff)
+		return TRgb(0x00ffffff);
+	else if (aIndex == 215)
+		return TRgb(0x00dd00dd);
+	else if (aIndex < StandardGrayBase)
+		{
+		return TRgb(KColorCubeMap[aIndex/36], KColorCubeMap[(aIndex/6)%6], KColorCubeMap[aIndex%6]);
+		}
+	else if (aIndex < SchemeSpecificColorBase)
+		{
+		int gray = aIndex - StandardGrayBase;
+		return TRgb(KStandardGray[gray], KStandardGray[gray], KStandardGray[gray]);
+		}
+	else
+		{
+		return TRgb(KSchemeRed[aIndex - SchemeSpecificColorBase]);
+		}
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/Color/src/strings.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* 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 "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:
+*
+*/
+const char* gIntroText ="\
+/*\n\
+* ============================================================================\n\
+*  Name     : %s.h\n\
+*  Part of  : Palette\n\
+*\n\
+*  Description:\n\
+*       Provides the K%sColor256Util definition.\n\
+*\n\
+*  Version:\n\
+*\n\
+*  Copyright (C) 2002 Nokia Corporation.\n\
+*  This material, including documentation and any related\n\
+*  computer programs, is protected by copyright controlled by\n\
+*  Nokia Corporation. All rights are reserved. Copying,\n\
+*  including reproducing, storing,  adapting or translating, any \n\
+*  or all of this material requires the prior written consent of \n\
+*  Nokia Corporation. This material also contains confidential \n\
+*  information which may not be disclosed to others without the \n\
+*  prior written consent of Nokia Corporation.\n\
+*\n\
+* ============================================================================\n\
+*/\n\
+\n\
+#if !defined(__%s_H__)\n\
+#define __%s_H__\n\
+\n\
+#include <gdi.h>\n\
+\n\
+\n\
+const TColor256Util K%sColor256Util =\n\
+	{\n\
+	// color256array\n\
+	{\n\
+";
+
+
+const char* gMiddleText ="\
+	},\n\
+	//color256inverse\n\
+	{\n\
+";
+
+
+const char* gEndText ="\
+	}\n\
+	};\n\
+\n\
+#endif\n\
+\n\
+// End of file\n\
+";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/DISTRIBUTION.POLICY	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,2 @@
+Category T
+OSD:	Reference/Test	Bitmap and font conversion utilities (GDITOOLS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/EFF.CPP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#include "FONTCOMP.H"
+
+EffRead::EffRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf,short int* aMapSpace):
+	FontRead(aFile,aFontCompiler,aFxf),
+	iMapSpace(aMapSpace)
+	{}
+
+int EffRead::ReadFont()
+    {
+	int count=0;
+	int version=0;
+	char* outbuffer[(MAX_CHAR_WID+7)>>3];
+	int bitpos,len1,len2;
+	int ReadSize,widToGo;
+	int widthofi=0;
+	int widthofM=0;
+	FcmCharHead* pFxf;
+	LetterTableData lettertabledata;
+	LetterData letterdata;
+	letterdata.blx = 0;
+	letterdata.bly = 0;
+	letterdata.rWid = 0;
+	letterdata.rHgt = 0;
+	int FileSize,FontNameOffs,VariousDataOffs,LetterOffs,LetterOffsBase,seekpos;
+	unsigned short int* pDest;
+	unsigned short int* pSrc;
+	EffVariousData VariousData;
+
+	char* inBuffer=new char[((MAX_CHAR_WID+7)>>3)*MAX_HEIGHT];
+	if(!inBuffer) return(NoMemory);
+	iInputFile.read((char*)&FileSize,4);
+	iInputFile.read((char*)&FontNameOffs,4);
+	iInputFile.read((char*)&VariousDataOffs,4);
+	iInputFile.read((char*)&VariousDataOffs,4);
+	iInputFile.read((char*)&LetterOffs,4);
+	iInputFile.seekg(FontNameOffs);
+
+	char tmpName[FONT_NAME_LEN+1];
+	iInputFile.read(tmpName,FONT_NAME_LEN);
+	tmpName[FONT_NAME_LEN]=0;
+	strcpy(iFxf->name,tmpName);
+	*(iFxf->typeface)=0;
+
+	iInputFile.seekg(VariousDataOffs);
+	iInputFile.read((char*)&VariousData,sizeof(VariousData));
+	version=VariousData.version;
+	if(version==0) version=1;
+	if(version!=1 && version!=2) return(FileFormat);
+	pFxf=new FcmCharHead[MAX_CHARS];
+	for(count=0;count<sizeof(FcmCharHead)*MAX_CHARS;count++)
+		((char*)pFxf)[count]=0;
+	int offset=0;
+	int first=1;
+	LetterOffsBase=LetterOffs;
+	iFxf->descent= -VariousData.bly;
+	iFxf->UlinePos= -VariousData.UnderLinePos-VariousData.UnderLineThickness;
+	iFxf->UlineThickness=VariousData.UnderLineThickness;
+	iFxf->nominal_ascent=(VariousData.Hgt/*+VariousData.LineSpacing*/)-iFxf->descent;
+	iFxf->MaxChrWidth=0;
+	iFxf->cell_height=VariousData.Hgt;
+	for(unsigned int chNum=0;chNum<MAX_CHARS;chNum++)
+		{
+		if(iMapSpace)
+			iInputFile.seekg((*(iMapSpace+chNum)<<2)+LetterOffsBase);
+		else
+			iInputFile.seekg(LetterOffs);
+		iInputFile.read((char*)&lettertabledata,sizeof(LetterTableData));
+		if(version==1)
+			{
+			lettertabledata.width>>=4;
+			iInputFile.read((char*)&letterdata,sizeof(LetterData));
+			LetterOffs+=sizeof(LetterData);
+			}
+		LetterOffs+=sizeof(LetterTableData);
+		iFxf->chr[chNum]=0;
+// char 0 in EFF fonts have a garbage offset so ignore them.
+//		if(letterdata.offset)
+		if(lettertabledata.offset && chNum>0)
+			{
+			seekpos=LetterOffsBase+lettertabledata.offset;
+			iInputFile.seekg(seekpos);
+			if(version==2)
+				iInputFile.read((char*)&letterdata,sizeof(LetterData));
+			if(first)
+				{
+				iFxf->FirstChr=chNum;
+				first=0;
+				}
+			iFxf->n_chars=chNum+1;
+			iFxf->chr[chNum]=pFxf;
+			pFxf->offset=offset;
+			pFxf->xOffset=letterdata.blx;
+			pFxf->yOffset=letterdata.rHgt+letterdata.bly;
+			pFxf->width=letterdata.rWid;
+			if(chNum=='i')
+				widthofi=pFxf->width;
+			if(chNum=='M')
+				widthofM=pFxf->width;
+			pFxf->ByteWid=((pFxf->width+15)>>3)&(~1);
+			pFxf->height=letterdata.rHgt;
+			pFxf->move=lettertabledata.width;
+			int chWid=letterdata.rWid;
+			if(chWid>iFxf->MaxChrWidth)
+			    iFxf->MaxChrWidth=chWid;
+			ReadSize=(letterdata.rWid*letterdata.rHgt+7)>>3;
+			iInputFile.read(inBuffer,ReadSize);
+			bitpos=0;
+			pSrc=(unsigned short int*)inBuffer;
+			for(int i=0;i<letterdata.rHgt;i++)
+			    {
+			    pDest=(unsigned short int*)outbuffer;
+			    for(int j=0;j<pFxf->ByteWid;j+=2)
+			        {
+			        len1=16-bitpos;
+			        *pDest=(unsigned short int)((*pSrc)>>bitpos);
+			        widToGo=letterdata.rWid-(j<<3);
+			        if (len1>widToGo)
+			            {
+			            len1=widToGo;
+			            len2=0;
+			            }
+			        else
+			            {
+			            pSrc++;
+			            if ((len1+bitpos)>widToGo)
+			                len2=widToGo-len1;
+			            else
+			                len2=bitpos;
+			            if (len2)
+			                *pDest|= (*pSrc)<<(16-bitpos);
+			            }
+			        *pDest&=0xFFFF>>(16-len2-len1);
+			        bitpos=(bitpos+len1+len2)&0xF;
+			        pDest++;
+			        }
+				memcpy(iFontCompiler->FontStore()+offset+pFxf->ByteWid*(letterdata.rHgt-i-1),outbuffer,pFxf->ByteWid);
+			    }
+			offset+=pFxf->ByteWid*letterdata.rHgt;
+			}
+        pFxf++;
+        }
+	if(widthofi && widthofM)
+		iFxf->iProportional=(widthofi!=widthofM);
+	return(NoError);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/FONTCOMP.CPP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#include "FONTCOMP.H"
+
+FontCompiler::FontCompiler():
+	iInputFile(),
+	iOutputFile(),
+	iFxf(NULL),
+	iFontSpace(NULL),
+	iWorkSpace(NULL),
+	iMapSpace(NULL),
+	iWorkSpaceSize(0),
+	iHeaderDataLen(0),
+	iHeaderData()
+	{}
+
+int FontCompiler::Init(char* infile,char* outfile,char* mapfile)
+	{
+	if(mapfile)
+		{
+		iMapSpace=new short int[256];
+		if(!iMapSpace) return(NoMemory);
+
+#ifdef __MSVCDOTNET__
+		fstream tempfile(mapfile, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+		fstream tempfile(mapfile, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+		if(!tempfile.is_open())
+			return(NoFile);
+		tempfile.read((char*)iMapSpace,512);
+		tempfile.close();
+		}
+	iOutputFile.open(outfile, ios::out);
+
+#ifdef __MSVCDOTNET__
+	iInputFile.open(infile, ios::in | ios::binary);
+#else //!__MSVCDOTNET__
+	iInputFile.open(infile, ios::in | ios::binary | ios::nocreate);
+#endif //__MSVCDOTNET__
+
+	if(!(iOutputFile.is_open() && iInputFile.is_open()))
+		return(NoFile);
+	iFxf=new Fxf;
+	if(!iFxf) return(NoMemory);
+	iFxf->iBold=0;
+	iFxf->iItalic=0;
+	iFxf->iProportional=0;
+	iFxf->iSerif=0;
+	iFxf->iSymbol=0;
+	iFxf->iUid=0;
+	iFontSpace=new char[0x100000];
+	if(!iFontSpace) return(NoMemory);
+	return(NoError);
+	}
+
+char* FontCompiler::FontStore() const
+	{
+	return(iFontSpace);
+	}
+
+int FontCompiler::Read(FontType aInputType)
+	{
+	FontRead *read=NULL;
+	switch(aInputType)
+		{
+		case EFontTypeFsc:
+			read=new FscRead(iInputFile,*this,iFxf);
+			break;
+		case EFontTypeEff:
+			read=new EffRead(iInputFile,*this,iFxf,iMapSpace);
+			break;
+		default:
+			return(Parameter);
+		}
+	if(!read)
+		return(NoMemory);
+	int error=read->ReadFont();
+	delete read;
+	return(error);
+	}
+
+void FontCompiler::RemoveBlankSpace()
+	{
+	int count=0;
+	const int maxbytewidth=(MAX_CHAR_WID+15)>>3;
+	unsigned char buf[maxbytewidth];
+	unsigned char zbuf[maxbytewidth];
+
+	for(count=0;count<maxbytewidth;count++)
+			zbuf[count]=0;
+	for(int chNum=iFxf->FirstChr;chNum<iFxf->n_chars;chNum++)
+		{
+		FcmCharHead *fChar=iFxf->chr[chNum];
+		if(fChar)
+		    {
+		    int LastNonBlank=0;
+		    int TopCount=0;
+		    int MinLeftBlank=fChar->width;
+		    int MinRightBlank=0;
+		    
+       	    // DEF102183: Graphics tools fail to build using MS VC8.
+		    int row;
+		    int x;
+		    for(row=0;row<fChar->height;)
+			{
+				memcpy(buf,iFontSpace+fChar->offset+fChar->ByteWid*row,fChar->ByteWid);
+			unsigned char bit=1;
+			unsigned char* pb=buf;
+			for(x=0;x<MinLeftBlank;x++)
+			    {
+			    if ((*pb)&bit)
+				{
+				MinLeftBlank=x;
+				break;
+				}
+			    bit<<=1;
+			    if (bit==0)
+				{
+				bit=1;
+				pb++;
+				}
+			    }
+			bit=(unsigned char)(1<<((fChar->width-1)%8));
+			pb=&buf[((fChar->width-1)>>3)];
+			for(x=fChar->width;x>MinRightBlank;x--)
+			    {
+			    if ((*pb)&bit)
+				{
+				MinRightBlank=x;
+				break;
+				}
+			    bit>>=1;
+			    if (bit==0)
+				{
+				bit=unsigned char(0x80);
+				pb--;
+				}
+			    }
+			row++;
+				if(memcmp(zbuf,buf,fChar->ByteWid))
+			    {
+			    if (TopCount==0)
+				TopCount=row;   /* Count of blank rows at the top */
+			    LastNonBlank=row;
+			    }
+			}
+		    if (TopCount==0)
+			{
+			fChar->height=0;
+			fChar->width=0;
+			fChar->xOffset=0;
+			fChar->yOffset=0;
+			}
+		    else
+			{
+			TopCount--;
+			fChar->height=LastNonBlank-TopCount;
+			fChar->width=MinRightBlank-MinLeftBlank;
+			fChar->yOffset-=TopCount;
+			fChar->offset+=TopCount*fChar->ByteWid;
+			fChar->xOffset+=MinLeftBlank;
+			if (MinLeftBlank)
+			    {
+			    int byte_step=MinLeftBlank/8;
+			    int bit_shift=MinLeftBlank%8;
+			    unsigned char mask=(unsigned char)(0xFF>>(7-((fChar->width-1)%8)));
+			    for(row=0;row<fChar->height;row++)
+						{
+						memcpy(buf,iFontSpace+fChar->offset+fChar->ByteWid*row,fChar->ByteWid);
+						for(x=0;x<(fChar->ByteWid-byte_step);x++)
+							buf[x]=(unsigned char)((buf[x+byte_step]>>bit_shift)+
+								(buf[x+byte_step+1]<<(8-bit_shift)));
+						buf[x-1]&=mask;
+						memcpy(iFontSpace+fChar->offset+fChar->ByteWid*row,buf,fChar->ByteWid);
+						}
+			    }
+			}
+		    }
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/FONTCOMP.H	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,241 @@
+/*
+* Copyright (c) 1997-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#if !defined(__FONTCOMP_H__)
+#define __FONTCOMP_H__
+#include <stdlib.h>
+#include <string.h>
+#include <io.h>
+
+#ifdef __MSVCDOTNET__
+#include <fstream>
+#include <iostream>
+using namespace std;
+#else //!__MSVCDOTNET__
+#include <fstream.h>
+#endif //__MSVCDOTNET__
+
+/**
+@internalComponent
+*/
+#define MAX_CHARS 256
+#define FONT_NAME_LEN 16
+/**
+@internalComponent
+*/
+#define MAX_CHAR_WID 256
+#define MAX_HEIGHT 256
+#define MAX_LABEL_LENGTH 16		/* Max font label name */
+#define MAX_LEN_IN 255	/* Max input line length */
+#define MAXLINE 600	/* Max line length for writing to screen */
+#define FONT_MAX_HEADER_LEN 128
+#define P_FNAMESIZE 128 /* Maximum file name size */
+/**
+@internalComponent
+*/
+enum Errors
+	{
+	NoError=0,
+	NoMemory=-1,
+	NoFile=-2,
+	FileRead=-3,
+	FileWrite=-4,
+	FileFormat=-5,
+	Parameter=-6
+	};
+/**
+@internalComponent
+*/
+struct FcmCharHead
+	{
+	int xOffset;
+	int yOffset;
+	int width;
+	int height;
+	int move;
+	int ByteWid;
+	int offset;
+	};
+/**
+@internalComponent
+*/
+struct LetterTableData
+	{
+	short int offset;
+	short int width; /* x16 in version 1*/
+	};
+/**
+@internalComponent
+*/
+struct LetterData
+	{
+	char blx;
+	char bly;
+	unsigned char rWid; /* Enclosing rectangle width */
+	unsigned char rHgt; /* Enclosing rectangle height */
+	};
+/**
+@internalComponent
+*/
+struct EffVariousData
+	{
+	short int version;
+	short int blx;
+	short int bly;
+	short int Wid;
+	short int Hgt;
+	short int xSize; /* 16 x Point size */
+	short int xRes;  /* DPI */
+	short int ySize;
+	short int yRes;
+	unsigned char XHeight;
+	unsigned char CapHeight;
+	unsigned char Ascender;
+	char Descender;
+	unsigned char LineSpacing;
+	char UnderLinePos;
+	unsigned char UnderLineThickness;
+	unsigned char filler[7];
+	};
+/**
+@internalComponent
+*/
+const int EMaxFontNameLength=256;
+
+class Fxf
+/**
+@internalComponent
+*/
+	{
+public:
+	FcmCharHead *chr[MAX_CHARS];
+	char name[EMaxFontNameLength]; /* Font name */
+	char typeface[EMaxFontNameLength]; /* Font typeface */
+	int MaxChrWidth;
+	int cell_height;      /* Height of character set */
+	int nominal_ascent;   /* Max ascent of normal (ASCII) characters */
+	int descent;         /* Descent of characters below base line */
+	int chr_seg;
+	int FirstChr;
+	int n_chars;         /* counts total number of characters defined */
+	unsigned int max_info_width;  /* Max char width to put in info file */
+	unsigned short int flags;
+	unsigned short int special;
+	unsigned int ByteWid;
+	int UseWords;
+	int UlinePos;
+	int UlineThickness;
+	int iBold;
+	int iItalic;
+	int iProportional;
+	int iSerif;
+	int iSymbol;
+	unsigned int iUid;
+	};
+/**
+@internalComponent
+*/
+enum FontType
+	{
+	EFontTypeFsc,
+	EFontTypeEff
+	};
+
+class FontCompiler
+/**
+@internalComponent
+*/
+	{
+public:
+	FontCompiler();
+	int Read(FontType aInputType);
+	int Init(char*,char*,char*);
+	void RemoveBlankSpace();
+	char* FontStore() const;
+	virtual int WriteFont()=0;
+protected: // general information
+	fstream iInputFile;
+	fstream iOutputFile;
+	Fxf* iFxf;
+protected: // font information
+	char* iFontSpace;
+	char* iWorkSpace; // misc. stuff
+	short int* iMapSpace;
+	int iWorkSpaceSize;
+	unsigned int iHeaderDataLen;
+	unsigned char iHeaderData[FONT_MAX_HEADER_LEN];
+	};
+
+class FontRead
+/**
+@internalComponent
+*/
+	{
+public:
+	FontRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf);
+	virtual int ReadFont()=0;
+private:
+	FontRead& operator=(const FontRead&);
+protected:
+	fstream& iInputFile;
+	FontCompiler* iFontCompiler;
+	Fxf* iFxf;
+	};
+
+class EffRead : public FontRead
+/**
+@internalComponent
+*/
+	{
+public:
+	EffRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf,short int* aMapSpace);
+	virtual int ReadFont();
+private:
+	EffRead& operator=(const EffRead&);
+private:
+	short int* iMapSpace;
+	};
+
+class FscRead : public FontRead
+/**
+@internalComponent
+*/
+	{
+public:
+	FscRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf);
+	virtual int ReadFont();
+private:
+	FscRead& operator=(const FscRead&);
+private:
+	int ReadLine();
+	int Pass1();
+	int Pass2();
+	char* ScanLine(int& aLen);
+	int DoCom(int aSecondPass);
+private:
+	FcmCharHead *iChar;
+	char iInputBuf[256];
+	int iInputBufLen;
+	char* iFileBuf;
+	int iFileBufLen;
+	int iFileBufPos;
+	int iUnderHang;
+	int iOverHang;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/FSC.CPP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,337 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#include "FONTCOMP.H"
+
+FscRead::FscRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf):
+	FontRead(aFile,aFontCompiler,aFxf)
+	{}
+
+int FscRead::DoCom(int aSecondPass)
+/*
+Takes a command and takes appropriate action
+Returns -ve if an error occured
+        0 for OKAY
+        +ve number for new current character number
+*/
+    {
+    int ret=0,num=0,neg=0;
+	int i=0;
+    for (;i<iInputBufLen;i++)
+        {
+		char chr=iInputBuf[i];
+        if (num==0 && chr=='-')
+            neg=1;
+        else if (chr>='0' && chr<='9')
+            num=num*10+chr-'0';
+        }
+    if (neg)
+        num= -num;
+    if (iInputBuf[1]=='c')
+        return(num);
+    if (aSecondPass)
+        ret=0;
+    else switch(iInputBuf[1])
+        {
+        case 'd':
+            iFxf->descent=num;
+            break;
+        case 'a':
+            iFxf->nominal_ascent=num;
+            break;
+        case 'm':
+            iFxf->max_info_width=num;
+            break;
+        case 'h':
+            if ((iFxf->cell_height=num)>MAX_HEIGHT)
+                ret=Parameter;
+            if (iFxf->nominal_ascent==0)
+                iFxf->nominal_ascent=iFxf->cell_height-iFxf->descent;
+            break;
+        case 'n':       /* Font data label name */
+			{
+			int pos=0;
+			while(iInputBuf[pos]!=' ')
+				pos++;
+			while(iInputBuf[pos]==' ')
+				pos++;
+			if(iInputBufLen-pos>FONT_NAME_LEN)
+		        return(FileFormat);
+			memcpy(iFxf->name,&iInputBuf[pos],iInputBufLen-pos);
+			(iFxf->name)[iInputBufLen-pos]=0;
+			}
+            break;
+        case 't':       /* Font data typeface */
+			{
+			int pos=0;
+			while(iInputBuf[pos]!=' ')
+				pos++;
+			while(iInputBuf[pos]==' ')
+				pos++;
+			if(iInputBufLen-pos>FONT_NAME_LEN)
+		        return(FileFormat);
+			memcpy(iFxf->typeface,&iInputBuf[pos],iInputBufLen-pos);
+			(iFxf->typeface)[iInputBufLen-pos]=0;
+			}
+            break;
+        case 'b':
+			iFxf->iBold=1;
+            break;
+        case 'i':
+			iFxf->iItalic=1;
+            break;
+        case 'f':
+			// not a lot
+            break;
+        case 'v':
+			iFxf->iUid=num;
+            break;
+        case 'o':
+			iOverHang=num;
+            break;
+        case 'u':
+			iUnderHang=num;
+            break;
+        default:
+            ret=FileFormat;
+            break;
+        }
+    return(ret);
+    }
+
+char* FscRead::ScanLine(int& aLen)
+/* Scan the input line for the first '0' or '1' character and return a descriptor pointing to it,
+returns a zero length descriptor if not found.
+*/
+    {
+	aLen=0;
+	if((iInputBuf[0]!='0' && iInputBuf[0]!='1') || iInputBufLen==0)
+		return(NULL);
+	while(iInputBuf[aLen]=='0' || iInputBuf[aLen]=='1')
+		aLen++;
+	return(iInputBuf);
+    }
+
+
+int FscRead::ReadLine()
+	{
+	int pos=0;
+	while(iFileBuf[iFileBufPos+pos]!='\n' && iFileBufPos+pos<iFileBufLen)
+		pos++;
+	if(iFileBufPos+pos==iFileBufLen) return(1);
+	memcpy(iInputBuf,&iFileBuf[iFileBufPos],pos);
+	iInputBufLen=pos-1;
+	iFileBufPos+=pos+1;
+	if(iFileBufPos>=iFileBufLen) return(1);
+	return(0);
+	}
+
+FontRead::FontRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf):
+	iInputFile(aFile),
+	iFontCompiler(&aFontCompiler),
+	iFxf(aFxf)
+	{
+	}
+
+int FscRead::ReadFont()
+	{
+	iInputFile.seekg(0,ios::end);
+	iFileBufLen=iInputFile.tellg();
+	iInputFile.seekg(0);
+	iFileBufPos=0;
+	iFileBuf=new char[iFileBufLen];
+	iInputFile.read(iFileBuf,iFileBufLen);
+	int ret=Pass1();
+	if(ret) return(ret);
+	return(Pass2());
+	}
+
+int FscRead::Pass1()
+    {
+    int n_row=0;            	// counts row in character picture
+    int ret=0;
+    int specChr=0;
+	int isCharBody=0;
+	int lastLine=0;
+	int widthofi=0;
+	int widthofM=0;
+
+	iFxf->MaxChrWidth=0;
+	iFxf->cell_height=0;
+	iFxf->UlinePos=0;
+	iFxf->UlineThickness=0;
+	iFxf->nominal_ascent=0;
+	iFxf->descent=0;
+	iFxf->chr_seg=0;
+	iFxf->FirstChr=0;
+	iFxf->n_chars=0;
+	iFxf->max_info_width=0;
+	iFxf->flags=0;
+	iFxf->special=0;
+	iFxf->ByteWid=0;
+	iFxf->UseWords=0;
+	iFxf->iBold=0;
+	iFxf->iItalic=0;
+	iFxf->iProportional=0;
+	iFxf->iSerif=0;
+	iFxf->iSymbol=0;
+	iFxf->iUid=0;
+
+	iUnderHang=0;
+    iOverHang=0;
+    iChar=new FcmCharHead[MAX_CHARS];
+    for(int letter=0;letter<MAX_CHARS;letter++)
+        iFxf->chr[letter]=NULL;
+//**************************************************
+// First pass. Read header info & character widths *
+//**************************************************
+    do
+        {
+	    int width=0;         	// width of current character picture
+
+		lastLine=ReadLine();
+		isCharBody=0;
+        if (iInputBufLen>0 && iInputBuf[0]=='*')
+            {
+            if ((ret=DoCom(0))<0)
+                  return(FileFormat);
+            else if (ret)
+                {
+                for(;iFxf->n_chars<ret;iFxf->n_chars++)
+                    iFxf->chr[iFxf->n_chars]=NULL;
+                specChr=iFxf->n_chars;
+                }
+            }
+        else
+            {
+			int len=0;
+		    char* ptr=ScanLine(len);
+            if (len)
+                {
+				isCharBody=1;
+                if (iFxf->FirstChr<0)
+                    iFxf->FirstChr=iFxf->n_chars;
+                if (n_row==0)
+                    {
+                    for (width=0;width<len && (ptr[width]=='0' || ptr[width]=='1');width++);
+                    if (iFxf->n_chars>255)
+                        return(FileFormat);
+                    iFxf->chr[iFxf->n_chars]=iChar;
+                    iFxf->n_chars++;
+                    iChar->xOffset= -iUnderHang;
+                    iChar->width=width;
+                    iChar->ByteWid=((iChar->width+15)>>3)&(~1);
+                    iChar->move=width-iUnderHang-iOverHang;
+					if(iFxf->n_chars=='i')
+						widthofi=iChar->move;
+					else if(iFxf->n_chars=='M')
+						widthofM=iChar->move;
+                    iUnderHang=0;
+                    iOverHang=0;
+                    if (width>iFxf->MaxChrWidth)
+                        iFxf->MaxChrWidth=width;
+                    }
+                n_row++;
+                }
+            }
+        if ((n_row!=0 && !isCharBody) || (lastLine && isCharBody))
+            {
+            if (n_row>iFxf->cell_height)
+                return(FileFormat);
+            iChar->height=n_row;
+            iChar->yOffset=iFxf->cell_height-iFxf->descent;
+            specChr++;
+            n_row=0;
+            width=0;
+            iChar++;
+            }
+        } while(!lastLine);
+    if (iFxf->cell_height==0)
+        return(FileFormat);
+	if(widthofi && widthofM)
+		iFxf->iProportional=(widthofi!=widthofM);
+	return(NoError);
+	}
+
+int FscRead::Pass2()
+/******************************************************/
+/* Second pass. Read in actual picture data this time */
+/******************************************************/
+	{
+	unsigned int bit;            	// Used to set bits in pic
+	int ret,chNum;
+	int n_row;            	// counts row in character picture
+	int offset=0;
+	int isCharBody;
+	int lastLine;
+
+	iFileBufPos=0;
+	n_row=0;
+	chNum=0;
+	do	{
+		lastLine=ReadLine();
+		isCharBody=0;
+        if (iInputBufLen>0 && iInputBuf[0]=='*')
+            {
+            if ((ret=DoCom(1))>0)
+                {
+                if (ret<chNum)
+                    return(FileFormat);
+                chNum=ret;
+                }
+            }
+		else
+			{
+			int len=0;
+			char* ptr=ScanLine(len);
+			if (len)
+                {
+				isCharBody=1;
+                if (n_row==0)
+                    {
+                    iChar=iFxf->chr[chNum];
+                    chNum++;
+                    }
+				unsigned short int* pDest=(unsigned short int*)(iFontCompiler->FontStore()+offset+iChar->ByteWid*n_row);
+                bit=1;
+                *pDest=0;
+                for (int width=0;width<len && (ptr[width]=='0' || ptr[width]=='1');width++)
+                    {
+                    if (ptr[width]=='1')
+                        *pDest|=bit;
+                    if (bit==0x8000)
+                        {
+                        bit=1;
+                        pDest++;
+                        *pDest=0;
+                        }
+                    else
+                        bit<<=1;
+                    }
+                n_row++;
+                }
+            }
+        if ((n_row!=0 &&  !isCharBody) || (lastLine && isCharBody))
+            {
+            iChar->offset=offset;
+			offset+=iChar->ByteWid*n_row;
+            n_row=0;
+            }
+        } while(!lastLine);
+	return(NoError);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/GDSFCOMP.CPP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,234 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#include "GDSFCOMP.H"
+#include "TOOLSVER.H"
+
+int GdsFontCompiler::WriteFont()
+	{
+	int index=0;
+	index=WriteHeader();
+	if(index<0) return(index);
+	for(int ch=index;ch<iFxf->n_chars;ch++)
+		WriteCharData(ch);
+	WriteFooter();
+	return(NoError);
+	}
+
+int GdsFontCompiler::WriteHeader()
+	{
+	int mncw=0;
+	for(char letter='A';letter<='Z';letter++)
+		{
+		FcmCharHead* fChar=iFxf->chr[letter];
+		if(fChar)
+			{
+			int letterwidth=fChar->move;
+			if(letterwidth>mncw)
+				mncw=letterwidth;
+			}
+		}
+	WriteFormattedData("FontBitmap ");
+	WriteFormattedData(iFxf->name,1);
+	WriteFormattedData("Uid ");
+	WriteFormattedData(iFxf->iUid);
+	if(iFxf->iBold)
+		WriteFormattedData(" Bold");
+	if(iFxf->iItalic)
+		WriteFormattedData(" Italic");
+	if(iFxf->iProportional)
+		WriteFormattedData(" Proportional");
+	if(iFxf->iSerif)
+		WriteFormattedData(" Serif");
+	if(iFxf->iSymbol)
+		WriteFormattedData(" Symbol");
+	WriteNewLine();
+	WriteFormattedData("MaxNormalCharWidth ");
+	WriteFormattedData(mncw,1);
+	WriteFormattedData("CellHeight ");
+	WriteFormattedData(iFxf->cell_height,1);
+	WriteFormattedData("Ascent ");
+	WriteFormattedData(iFxf->nominal_ascent,1);
+//	WriteFormattedData("Uline ");
+//	WriteFormattedData(iFxf->UlinePos,0);
+//	WriteFormattedData(" ");
+//	WriteFormattedData(iFxf->UlineThickness,1);
+	int index=0;
+	while(!iFxf->chr[index])
+		index++;
+	if(index>=iFxf->n_chars)
+		return(FileFormat);
+	WriteFormattedData("CodeSection ");
+	WriteFormattedData(index,0);
+	WriteFormattedData(":");
+	WriteFormattedData(iFxf->n_chars-1,1);
+	return(index);
+	}
+
+void GdsFontCompiler::WriteFooter()
+	{
+	WriteFormattedData("EndCodeSection",1);
+	WriteFormattedData("EndFontBitmap",1);
+	WriteNewLine();
+	}
+
+void GdsFontCompiler::WriteCharData(int charnum)
+	{
+	unsigned short int* pSrc;
+	unsigned short int bit;
+	char buf[10+MAX_CHAR_WID];
+	unsigned short int srcBuf[(MAX_CHAR_WID+15)>>4];
+
+	const FcmCharHead* fChar=iFxf->chr[charnum];
+	WriteNewLine();
+	WriteFormattedData("Char ");
+	WriteFormattedData(charnum);
+	if(fChar==NULL)
+		{
+		WriteNewLine();
+		WriteFormattedData("EndChar",1);
+		return;
+		}
+	WriteFormattedData(" Adjust ");
+
+	int bitwid=fChar->move+(fChar->xOffset<0?-fChar->xOffset:0);
+	const int ohang=fChar->move-fChar->xOffset-fChar->width;
+	WriteFormattedData(fChar->xOffset);
+	WriteFormattedData(" ");
+	WriteFormattedData(ohang);
+	bitwid+=ohang;
+	if (charnum>31)
+		{
+		WriteFormattedData("  ! '");
+		WriteFormattedData((char*)&charnum);
+		WriteFormattedData("'");
+		}
+	WriteNewLine();
+	if (fChar->width!=0)
+		{
+		WriteBlankLines(iFxf->cell_height-iFxf->descent-fChar->yOffset,fChar->width);
+		for(int y=0;y<fChar->height;y++)
+			{
+			memcpy(srcBuf,iFontSpace+fChar->offset+y*fChar->ByteWid,fChar->ByteWid);
+			pSrc=&srcBuf[0];
+			bit=1;
+			int pb=0;
+			for(int i=0;i<fChar->width;i++)
+				{
+				buf[pb++]=((*pSrc)&bit)?SetPixel:BlankPixel;
+				bit<<=1;
+				if(!bit)
+					{
+					bit=1;
+					pSrc++;
+					}
+				}
+			buf[pb]=0;
+			WriteFormattedData(buf,1);
+			}
+		WriteBlankLines(iFxf->descent+fChar->yOffset-fChar->height,fChar->width);
+		}
+	WriteFormattedData("EndChar",1);
+	}
+
+void GdsFontCompiler::WriteBlankLines(int num,int width)
+	{
+	char buf[2+MAX_CHAR_WID+20];
+	memset(&buf[0],BlankPixel,width);
+	buf[width] ='\0';
+	for(int i=0;i<num;i++)
+		WriteFormattedData(buf,1);
+	}
+
+void GdsFontCompiler::WriteFormattedData(char* aData,int aNewLine)
+	{
+	if(aData)
+		iOutputFile << aData;
+	if(aNewLine)
+		WriteNewLine();
+	}
+
+void GdsFontCompiler::WriteFormattedData(int aNum,int aNewLine)
+	{
+	char numbuf[16];
+	_itoa(aNum,numbuf,10);
+	WriteFormattedData(numbuf,aNewLine);
+	}
+
+void GdsFontCompiler::WriteNewLine()
+	{
+	iOutputFile << "\n";
+	}
+
+int main(int argc,char *argv[])
+    {
+	if(argc<3 || argc>5)
+		{
+		cout << "\n";
+		cout << "FONTCOMP Version 0.01(" << version << ")\n";
+		cout << "\n";
+		cout << "USAGE: FONTCOMP srcfile destfile [/e [mapfile]|/f]\n";
+		cout << "Where srcfile is the file to be processed,\n";
+		cout << "destfile is the file to be created,\n";
+		cout << "/e specifies EFF format (default) and /f\n";
+		cout << "specifies FSC format.  If the format is EFF then\n";
+		cout << "the optional mapfile may be used for altenative\n";
+		cout << "character sets.\n\n";
+		return(0);
+		}
+	FontType type=EFontTypeEff;
+	if(argc==4)
+		if(argv[3][1]=='f' || argv[3][1]=='F')
+			type=EFontTypeFsc;
+	char* mapfile=NULL;
+	if(argc==5) mapfile=argv[4];
+	GdsFontCompiler fontcomp;
+	int ret=fontcomp.Init(argv[1],argv[2],mapfile);
+	if(ret==NoError)
+		ret=fontcomp.Read(type);
+	if(ret==NoError)
+		fontcomp.RemoveBlankSpace();
+	if(ret==NoError)
+		ret=fontcomp.WriteFont();
+	switch(ret)
+		{
+		case NoError:
+			cout << "Success\n\n";
+			break;
+		case NoMemory:
+			cout << "Out of memory\n\n";
+			break;
+		case NoFile:
+			cout << "File does not exist\n\n";
+			break;
+		case FileRead:
+			cout << "File read error\n\n";
+			break;
+		case FileWrite:
+			cout << "File write error\n\n";
+			break;
+		case FileFormat:
+			cout << "File has wrong format\n\n";
+			break;
+		case Parameter:
+			cout << "Bad parameter\n\n";
+			break;
+		}
+	return(ret);
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/fontcomp/GDSFCOMP.H	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#if !defined(__GDSFCOMP_H__)
+#define __GDSFCOMP_H__
+#if !defined(__FONTCOMP_H__)
+#include "FONTCOMP.H"
+#endif
+/**
+@internalComponent
+*/
+const char BlankPixel = '.';
+const char SetPixel = '*';
+
+class GdsFontCompiler : public FontCompiler
+/**
+@internalComponent
+*/
+	{
+public:
+	int WriteFont();
+protected:
+	int WriteHeader();
+	void WriteFooter();
+	void WriteCharData(int);
+	void WriteBlankLines(int,int);
+	void WriteFormattedData(char*,int=0);
+	void WriteFormattedData(int,int=0);
+	void WriteNewLine();
+	};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/group/DISTRIBUTION.POLICY	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,2 @@
+Category T
+OSD:	Reference/Test	Bitmap and font conversion utilities (GDITOOLS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/group/FONTCOMP.MMP	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET           fontcomp.exe
+
+TARGETTYPE       exe
+
+USERINCLUDE   ../inc
+USERINCLUDE ../../../inc
+USERINCLUDE ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH	    ../fontcomp
+SOURCE          eff.cpp fontcomp.cpp fsc.cpp gdsfcomp.cpp
+
+
+VENDORID 0x70000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/group/Makefile.bmconv	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,27 @@
+CXX	 = g++296
+CXXFLAGS =  -x c++ -g -D __LINUX__ -I $(EPOCROOT)epoc32/include -I ../inc
+SOURCE	 =  MAINFUNC.CPP BMTOPBM.CPP PBMCOMP.CPP PBMTOBM.CPP RGB.CPP UTILS.CPP
+BLDDIR	 = ../build-bmconv
+OBJECT   = $(addprefix $(BLDDIR)/, $(notdir $(SOURCE:.CPP=.o)))
+TARGET	 = $(BLDDIR)/bmconv
+
+VPATH	 = ../bmconv
+
+_dummy := $(shell mkdir -p $(BLDDIR))
+
+all: $(TARGET)
+
+
+$(TARGET): $(OBJECT)
+	$(CXX) $^ -o $@
+	
+	
+$(OBJECT): $(BLDDIR)/%.o: %.CPP
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+clean:
+	rm -f $(OBJECT) $(TARGET)
+	-rmdir $(BLDDIR)
+
+.PHONY: all clean
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 1999-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+/**
+@file
+
+@SYMPurpose PC-side graphics tools (e.g. BMCONV etc.)
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+
+PRJ_EXPORTS
+
+../group/fontcomp.ipr    /epoc32/engdoc/tools/fontcomp.ipr
+
+PRJ_MMPFILES
+
+#ifdef TOOLS
+
+../group/FONTCOMP.MMP
+
+// NOTICE! Bmconv is moved to /s60/tools/platformtools/gfxtools/bmconv/group
+
+#endif
+
+
+PRJ_TESTMMPFILES
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/group/fontcomp.ipr	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,17 @@
+[purpose]
+
+Compiles FSC and EFF format fonts into font store files
+
+[categories]
+obsolete-development
+
+[files]
+tools\fontcomp.exe	# compiler
+tools\fsc2bdf.exe	# alternative - convert FSC font to BDF
+
+[owner]
+Runtime & Tools		# GDITOOLS
+
+[IPR]
+Copyright (c) 2000 Symbian Ltd.  All rights reserved.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/inc/DISTRIBUTION.POLICY	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,2 @@
+Category T
+OSD:	Reference/Test	Bitmap and font conversion utilities (GDITOOLS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/inc/TOOLSVER.H	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 1997-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+#ifndef __TOOLSVER_H__
+#define __TOOLSVER_H__
+/**
+@internalComponent
+*/
+const int version=116;
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/gditools/rom/gdi.iby	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef __GDI_IBY__
+#define __GDI_IBY__
+
+REM GDI - Abstract Graphics API
+
+#include <palette.iby> /* gdi is only user */
+
+file=ABI_DIR\BUILD_DIR\gdi.dll 	System\Libs\Gdi.dll
+file=ABI_DIR\BUILD_DIR\linebreak.dll   System\Libs\linebreak.dll
+file=ABI_DIR\BUILD_DIR\lookuptable.dll  System\Libs\lookuptable.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gfxtools/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,19 @@
+/*
+* 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 "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:
+*
+*/
+
+#include "../gditools/group/bld.inf"
+#include "../Color/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* 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 "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:
+*
+*/
+
+#include "../uitools_plat/group/bld.inf"
+#include "../uitools_pub/group/bld.inf"
+#include "../cdlcompilertoolkit/group/bld.inf"
+#include "../cdlcompiler/group/bld.inf"
+#include "../gfxtools/group/bld.inf"
+#include "../aknlayoutcompiler/group/bld.inf"
+#include "../skincompiler/group/bld.inf"
+#include "../reszip/group/bld.inf"
+#include "../svgtencoder/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/uitools" >
+]>
+
+<SystemDefinition name="uitools" schema="1.4.0">
+  <systemModel>
+    <layer name="tools_layer">
+      <module name="uitools">
+        <unit unitID="abs.uitools" mrp="" bldFile="&layer_real_source_path;/group" name="uitools" />
+      </module>
+      <module name="">
+        <unit unitID="abs.uitools.toollibraries" mrp="" bldFile="&layer_real_source_path;/toollibraries/group" name="uitools_toollibraries" filter="!sf_build" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="uitools" name="UI Tools" levels="compile encode tool if">
+    <collection id="gfxtools" name="Graphics Tools" level="tool">
+      <component id="gditools" filter="s60" name="GDI Tools" target="desktop">
+        <unit bldFile="gfxtools/gditools/group"/>
+      </component>
+      <component id="color" filter="s60" name="Bitmap Colour Palette" target="desktop">
+        <unit bldFile="gfxtools/color/group"/>
+      </component>
+    </collection>
+    <collection id="reszip" name="Resource Zip" level="encode">
+      <component id="reszip_build" filter="s60" name="Resource Zip Build">
+        <unit bldFile="reszip/group"/>
+      </component>
+    </collection>
+    <collection id="toollibraries" name="Tool Libraries" level="tool"/>
+    <collection id="svgtencoder" name="SVGT Encoder" level="encode">
+      <component id="svgtenc" filter="s60" name="SVGT Encoder" target="desktop">
+        <unit bldFile="svgtencoder/svgtenc/standalone/group"/>
+      </component>
+    </collection>
+    <collection id="uitools_info" name="UI Tools Info" level="if">
+      <component id="uitools_plat" filter="s60" name="UI Tools Platform Interfaces" class="api">
+        <unit bldFile="uitools_plat/group"/>
+      </component>
+      <component id="uitools_pub" filter="s60" name="UI Tools Public Interfaces" class="api">
+        <unit bldFile="uitools_pub/group"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../group/reszip_eka2.bat /epoc32/tools/reszip.bat
+//../tools/resourcetype.cmd /epoc32/tools/resourcetype.cmd
+
+PRJ_MMPFILES
+#ifndef TOOLS
+reszip.mmp
+#endif
+
+PRJ_TESTMMPFILES
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/group/reszip.bat	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,19 @@
+@echo off
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+@echo on
+
+\epoc32\release\winc\udeb\reszip.exe %1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/group/reszip.mmp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET        	reszip.exe
+TARGETTYPE    	exe
+
+USERINCLUDE   	../inc
+USERINCLUDE	../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+sourcepath	../src
+
+
+SOURCE		rcmp.cpp
+SOURCE		rescomp.cpp
+SOURCE		resdict.cpp
+SOURCE		resentry.cpp
+
+LIBRARY       euser.lib efsrv.lib estor.lib bafl.lib
+
+START WINC
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/group/reszip_eka2.bat	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,19 @@
+@echo off
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+@echo on
+
+\epoc32\release\winscw\udeb\reszip.exe -Dtextshell -D_epoc_drive_a=%~d1 -- a:%~pnx1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/inc/rescomp.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+
+#if !defined(__RESCOMP_H__)
+#define __RESCOMP_H__
+
+#include <e32base.h>
+#include <f32file.h>
+#include <s32file.h>
+
+class CDictArray;
+class CResEntry;
+
+class TBitWriter
+	{
+public:
+	TBitWriter(RWriteStream& aStream);
+	void WriteL(TInt aValue, TInt aBits);
+	void FlushL();
+private:
+	RWriteStream& iStream;
+	TInt iValue;
+	TInt iBitsWritten;
+	};
+
+class CResComp : public CBase
+	{
+public:
+	CResComp(CConsoleBase* aConsole);
+	~CResComp();
+	void LoadFileL(RFs& aFs, const TDesC& aFileName);
+	void CompressL();
+	void WriteFileL(RFs& aFs, const TDesC& aName);
+	TPtrC8 Resource(TInt aRes);
+	TInt FindInResources(TDesC8& aBuf, TInt aMax);
+	TInt OriginalFileSize();
+	TInt CompressedSize();
+	void DisplayStats();
+	TInt ResourceSize();
+	TBool IsValid();
+private:
+	void LoadBAFLCompressedFileL(RFs& aFs, const TDesC& aName);
+	void LoadUnCompressedFileL(RFs& aFs, const TDesC& aName);
+	TBool FileIsBAFLCompressedL(RFs& aFs, const TDesC& aName);
+
+	void OptimizeDict();
+	void FindEmbeddedDict(TDesC8& aMatch, TInt aStart);
+	void WriteHeaderL(RWriteStream& aStream);
+	void WriteDictionaryL(RWriteStream& aStream);
+	void WriteDictionaryHeaderL(RWriteStream& aStream);
+	void WriteDictionaryIndexL(RWriteStream& aStream);
+	void WriteDictionaryDataL(RWriteStream& aStream);
+	void WriteResourceL(RWriteStream& aStream);
+	void WriteResourceIndexL(RWriteStream& aStream);
+	void WriteResourceDataL(RWriteStream& aStream);
+	TInt CompressResourcesL(TInt aMaxDictEntries);
+	TInt AttemptCompressionL(TInt aMaxDictEntries);
+	void CheckForLongDataStringsL();
+private:
+	CConsoleBase* iConsole;
+	TUint8* iResData;
+	CDictArray* iDict;
+	TUint16* iResIndex;
+	CArrayPtrFlat<CResEntry>* iResArray;
+	TInt iResources;
+	TInt iFileLength;
+	TInt iCompressedSize;
+	TInt iLargestResourceSize;
+	TInt iMaxEntries;
+	TInt iBitsForDict;
+	TInt iBestCompression;
+	TInt iBestSize;
+	TInt iOriginalCompressedSize;
+public:
+	TBuf<80> iConOutput;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/inc/resdict.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+
+#if !defined(__RESDICT_H__)
+#define __RESDICT_H__
+
+#include <e32base.h>
+
+const TInt KMaxDictEntry = 80;
+
+class CResEntry;
+class CDictArray;
+class TBitWriter;
+
+
+class TDictEntry
+	{
+public:
+	TDictEntry();
+	void Close();
+	TInt Saved();
+	TDesC8& Data();
+	TInt Use();
+	void CreateEmbeddedDict(TInt aDictIndex,CDictArray* aDict);
+public:
+	TBufC8<KMaxDictEntry> iData;
+	TInt iUses;
+	TInt iRef;
+	CResEntry* iEmbedded;
+	};
+
+
+class CDictArray : public CArrayFixFlat<TDictEntry>
+	{
+public:
+	CDictArray();
+	~CDictArray();
+	TInt AddEntryL(TDesC8& aEntry);
+	void OrderedInsertL(TDictEntry& aEntry);
+	void SizedInsertL(TDictEntry& aEntry);
+	TInt DictionarySize();
+	TInt DictionarySizeWithoutIndex();
+	TInt BitSize(TInt aIndex);
+	void WriteBitStreamL(TInt aIndex, TBitWriter& aWriter);
+	CDictArray* DuplicateL();
+public:
+	TInt iDictionaryBits;
+	};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/inc/resentry.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+
+#if !defined(__RESENTRY_H__)
+#define __RESENTRY_H__
+
+#include <e32base.h>
+
+class CDictArray;
+class CResComp;
+class TBitWriter;
+
+enum TResType
+	{
+	EResTypePlain = 0,
+	EResTypeToken = 1,
+	EResTypeZeroSpaced = 2
+	};
+
+class TResComponent
+	{
+public:
+	TInt Size(TInt aDictionaryBits);
+	void WriteBitStreamL(TBitWriter& aWriter,TInt aDictionaryBits);
+public:
+	TResType iType;
+	TUint8* iData;
+	TInt iLength;
+	TInt iToken;
+	};
+
+class CResEntry : public CBase
+	{
+public:
+	CResEntry(CDictArray* aDict);
+	~CResEntry();
+	void AddPlainDataL(TUint8* aData, TInt aLength);
+	TInt Size(TInt aDictionaryBits);
+	void MatchDictL(TInt aDictIndex = -1);
+	void MatchSelfL(TInt aRes,CResComp* aResComp);
+//	void MatchZeroSpacedL();
+	void WriteBitStreamL(TBitWriter& aWriter,TInt aDictionaryBits);
+	void CheckForLongDataStringsL();
+private:
+	TBool DoMatchDictL(TResComponent& aComp, TInt aOffset, TInt aDictIndex);
+	TBool DoMatchSelfL(TResComponent& aComp, TInt aOffset, TInt aRes,CResComp* aResComp);
+//	TBool DoMatchZeroSpacedL(TResComponent& aComp, TInt aOffset);
+	void SplitPlainDataWithTokenL(TInt aComponent, TInt aToken, TInt aPosition);
+	void InsertTokenL(TInt aPosition, TInt aToken);
+	TBool MatchPreviousComponent(TInt aCompIndex, TDesC8& aMatch);
+	void SplitPlainDataWithZeroSpacedL(TInt aComponent, TInt aZeroSpacedStart, TInt aLength);
+public:
+	CArrayFixFlat<TResComponent>* iComponent;
+	CDictArray* iDict;
+	};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/src/rcmp.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,286 @@
+/*
+* 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 "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:
+*
+*/
+// RCMP.CPP
+//
+//
+
+#include <e32svr.h>
+#include <e32cons.h>
+#include <s32file.h>
+#include <s32mem.h>
+
+
+#include "rescomp.h"
+#include "resdict.h"
+#include "resentry.h"
+
+const TInt KConsWidth = 20;
+const TInt KConsHeight = 15;
+
+// TOOL version string (will be printed on command line so please keep upto date)
+_LIT(KReszipVersionString, "reszip version 2.0.0");
+
+LOCAL_D CConsoleBase* console;
+LOCAL_D RFs TheFs;
+LOCAL_D CTrapCleanup* TheTrapCleanup;
+
+LOCAL_D CArrayFixFlat<TFileName>* iFileList;
+
+TBuf<256> Arg;
+
+
+_LIT(KUncompressedExt,".orig");
+
+LOCAL_C void setupCleanup()
+//
+// Initialise the cleanup stack.
+//
+    {
+	TheTrapCleanup=CTrapCleanup::New();
+	}
+
+void AddToFileListL(const TDesC& aName);
+
+
+void AddFileListL(const TDesC& aName)
+	{
+	RDebug::Print(_L("Adding files from "));
+	RDebug::Print(aName);
+	
+	RFileReadStream stream;
+	User::LeaveIfError( stream.Open(TheFs, aName, EFileRead) );
+	CleanupClosePushL(stream);
+
+	TBuf<512> buf;
+	TInt ch = 0;
+	TInt err = KErrNone;
+	while(err == KErrNone)
+		{
+		TRAP(err, ch = stream.ReadUint8L());
+		if (err == KErrNone)
+			{
+			if (ch != 13 && ch != 10)
+				{
+				buf.Append(ch);
+				}
+			else
+				{
+				AddToFileListL(buf);
+				buf.Zero();
+				}
+			}
+		}
+
+	CleanupStack::PopAndDestroy();	// stream
+	}
+
+void AddToFileListL(const TDesC& aName)
+	{
+	if (aName.Length() == 0)
+		{
+		return;
+		}
+	RDebug::Print(aName);
+
+	if (aName[0] == '@')
+		{
+		AddFileListL(aName.Right(aName.Length()-1));
+		return;
+		}
+
+	TParse parse;
+	if (parse.Set(aName, NULL, NULL) != KErrNone)
+		{
+		return;
+		}
+	TFileName name(parse.NameAndExt());
+	TPtrC driveAndPath(parse.DriveAndPath());
+
+	CDir* fileList = NULL; 
+	CDir* dirList = NULL; 
+
+
+	// Report any missing files (not fatal, as we don't want to stop the list)
+	TEntry entry;
+	if((!parse.IsWild()) && TheFs.Entry(aName,entry) != KErrNone)
+		console->Printf(_L("Error: Cannot find %S\n"), &aName);
+			
+
+	TInt err = TheFs.GetDir(aName, KEntryAttNormal,ESortByName,fileList,dirList);	
+	if (err != KErrNone)
+		{
+		delete fileList;
+		delete dirList;
+		return;
+		}
+
+	TInt count = fileList->Count();
+
+	_LIT(KString,"%S\n"); 
+
+	TInt appendErr = KErrNone;
+	for (TInt i=0;i<count;i++) 
+		{
+		TFileName fullName(driveAndPath);
+		fullName.Append((*fileList)[i].iName);
+		TRAPD(appendErr, iFileList->AppendL(fullName) );
+		if(appendErr!=KErrNone)
+			break;
+		}
+
+	delete fileList;
+	delete dirList;
+	User::LeaveIfError(appendErr);
+	}
+
+
+
+void ProcessAllFilesL()
+	{
+	TInt totalSize = 0;
+	TInt totalCompressed = 0;
+
+	if (Arg.Length() == 0)
+		{
+		// Write help information
+		console->Printf(_L("ResZip ROM Resource Compressor (%S)\n------------------------------\n"), &KReszipVersionString);
+		console->Printf(_L("Syntax: ResZip [full path to resource files]\n"));
+		console->Printf(_L("        ResZip [@full path to text file containing resource filenames]\n"));
+		console->Printf(_L("e.g: ResZip r:\\epoc32\\release\\wins\\udeb\\z\\system\\data\\*.rsc\n"));
+		console->Printf(_L("     ResZip @r:\\files.txt\n"));
+		console->Printf(_L("         where r:\\files.txt contains list of filenames (wildcards allowed)\n"));
+		console->Printf(_L("Full Path may include wildcards for compressing all resources in a directory\n"));
+		console->Printf(_L("May be used to compress non-ROM resources, with lower run-time performance\n"));
+		return;
+		}
+
+	iFileList = new(ELeave)CArrayFixFlat<TFileName>(32);
+
+	AddToFileListL(Arg);
+
+	TInt filecount = iFileList->Count();
+
+	if (filecount == 0)
+		{
+		console->Printf(_L("No files to process\n"));
+		}
+	else
+		{
+		TBuf<80> buf;
+		buf.Format(_L("Processing %d files\n"), filecount);
+		console->Printf(buf);
+		console->Printf(_L("Name\t\t\t Resource\tOrig\tUncompressed\tNew\t%%\tDictSize\n"));
+		console->Printf(_L("====\t\t\t ========\t====\t============\t===\t==\t========\n"));
+		}
+
+	TTime startTime;
+	startTime.UniversalTime();
+
+	for (TInt ii=0; ii<filecount; ii++)
+		{
+
+		CResComp* compressor = new(ELeave)CResComp(console);
+		CleanupStack::PushL(compressor);
+
+		TFileName fullName(iFileList->At(ii));
+		compressor->LoadFileL(TheFs, fullName);
+		compressor->CompressL();
+
+		if (!compressor->IsValid())
+			{
+			console->Printf(_L("\r"));
+			console->Printf(compressor->iConOutput);
+			console->Printf(_L("Not compressed\n"));
+			}
+		else
+			{
+			compressor->DisplayStats();
+			totalSize += compressor->OriginalFileSize();
+			totalCompressed += compressor->CompressedSize();
+			TFileName newName(fullName);
+			newName.Append(KUncompressedExt);
+			TheFs.Delete(newName);
+			User::LeaveIfError(TheFs.Rename(fullName, newName));
+			TRAPD(err, compressor->WriteFileL(TheFs,fullName));
+			if(err != KErrNone)
+				{
+				TheFs.Delete(fullName);
+				TheFs.Rename(newName, fullName);
+				User::Leave(err);
+				}
+			}
+
+		CleanupStack::PopAndDestroy(compressor);	
+		}
+
+	console->Printf(_L("------------------------------\n"));
+	console->Printf(_L("Total File Size: %d bytes\n"), totalSize);
+	console->Printf(_L("Total Compressed Size: %d bytes\n"), totalCompressed);
+
+	if (totalSize > 0)
+		{
+		TInt compression = ((totalCompressed) * 100) / totalSize;
+		console->Printf(_L("Total Compression = %d %%\n"), compression);
+		}
+
+	TTime endTime;
+	endTime.UniversalTime();
+
+	TTimeIntervalSeconds seconds;
+	endTime.SecondsFrom(startTime, seconds);
+
+	TInt secs = seconds.Int();
+	
+	TInt mins = secs / 60;
+	TInt hour = mins / 60;
+
+	secs -= (mins * 60);
+	mins -= (hour * 60);
+
+	TBuf<80> time;
+	time.Format(_L("Total time: %02d:%02d:%02d"), hour, mins, secs);
+	console->Printf(time);
+
+	delete iFileList;
+	}
+
+
+void DoConsoleL()
+	{
+	console=Console::NewL(_L("EPOC32 - reszip"),
+		TSize(KConsWidth,KConsHeight));
+	CleanupStack::PushL(console);
+	//
+	User::CommandLine(Arg);
+	//
+	User::LeaveIfError( TheFs.Connect() );
+	//
+	TRAPD(r,ProcessAllFilesL());
+
+	if (r!=KErrNone)
+		console->Printf(_L("failed with code %d\n"), r);
+	CleanupStack::PopAndDestroy(); // console
+	TheFs.Close();
+	}
+
+GLDEF_C TInt E32Main()
+	{
+	setupCleanup();
+	TRAPD(err,DoConsoleL());
+	delete TheTrapCleanup;
+	return KErrNone;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/src/rescomp.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,802 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+
+#include "rescomp.h"
+#include <e32cons.h>
+#include <s32file.h>
+#include <s32mem.h>
+
+#include <barsc.h>
+
+#include "resdict.h"
+#include "resentry.h"
+
+//#define __DEBUG_WRITE_UNCOMPRESSED_BAFL_RESOURCE
+
+// TBit Writer
+
+TBitWriter::TBitWriter(RWriteStream& aStream)
+:iStream(aStream)
+	{
+	iValue = 0;
+	iBitsWritten = 0;
+	}
+
+void TBitWriter::WriteL(TInt aValue, TInt aBits)
+	{
+	// 1<< aBits is the max Value;
+
+	__ASSERT_DEBUG((1<<aBits) > aValue, User::Panic(_L("TBitWriter"),KErrOverflow));
+	if (aBits + iBitsWritten < 8)
+		{
+		// Not enough data to write a byte
+		iValue += (aValue << iBitsWritten);
+		iBitsWritten += aBits;
+		}
+	else
+		{
+		TInt bitsLeft = 8-iBitsWritten;
+		TInt mask = (1<<bitsLeft)-1;
+		TInt maskValue = (aValue & mask) << iBitsWritten;
+
+		iValue += maskValue;
+		iStream.WriteUint8L(iValue);
+//		RDebug::Print(_L("Writing: %b [0x%x]"), iValue, iValue);
+		
+		TInt newValue = aValue >> bitsLeft;
+		TInt bits = aBits - bitsLeft;
+		while (bits > 7)
+			{
+			iStream.WriteUint8L(newValue & 0xff);
+			bits -= 8;
+			newValue = (newValue >> 8);
+			}
+		iValue = newValue;
+		iBitsWritten=bits;
+		}
+	}
+
+void TBitWriter::FlushL()
+	{
+	if (iBitsWritten > 0)
+		{
+		iStream.WriteUint8L(iValue);
+		iValue = 0;
+		iBitsWritten=0;
+		}
+	}
+
+
+
+
+CResComp::CResComp(CConsoleBase* aConsole)
+:iConsole(aConsole)
+	{
+	}
+
+CResComp::~CResComp()
+	{
+	if (iResArray)
+		{
+		iResArray->ResetAndDestroy();
+		}
+	delete iResArray;
+	delete iResData;
+	delete iDict;
+	}
+
+
+void CResComp::LoadBAFLCompressedFileL(RFs& aFs, const TDesC& aName)
+	{
+
+	RResourceFile res;
+	res.OpenL(aFs, aName);
+	CleanupClosePushL(res);
+
+	// Count resources
+	TInt count = 0;
+
+// This code around ConfirmSigniture had to be added because some S60 resources don't seem to have signature and panic.
+// See	DEF019933 - RResourceFile::ConfirmSignatureL() needs to be more robust  
+
+	HBufC8* const resource=res.AllocReadLC(1);
+	if(resource->Length()==8) // 8 =Sizeof SSigRecord
+		{
+		res.ConfirmSignatureL(0);
+		}
+	CleanupStack::PopAndDestroy(resource);
+
+	TInt offset = res.Offset();
+	while (res.OwnsResourceId(count+offset+1))
+		{
+		count++;
+		};
+
+	const TInt KBufferGranularity = 1000;
+	CBufFlat* buffer = CBufFlat::NewL(KBufferGranularity);
+	CleanupStack::PushL(buffer);
+
+	CBufFlat* indexbuffer = CBufFlat::NewL(KBufferGranularity);
+	CleanupStack::PushL(indexbuffer);
+
+	RBufWriteStream stream;
+	stream.Open(*buffer);
+	CleanupClosePushL(stream);
+
+	RBufWriteStream indexstream;
+	indexstream.Open(*indexbuffer);
+	CleanupClosePushL(indexstream);
+
+	TInt total = 0;
+
+	for (TInt ii=0; ii<count; ii++)
+		{
+		indexstream.WriteUint16L(total+4);
+		HBufC8* data = res.AllocReadLC(ii+offset+1);
+		TInt len = data->Length();
+		total += len;
+		stream.WriteL(*data, len);
+		CleanupStack::PopAndDestroy();
+		}
+	indexstream.WriteUint16L(total+4);
+
+
+	indexstream.CommitL();
+	CleanupStack::PopAndDestroy();	// close indexstream
+
+	stream.CommitL();
+	CleanupStack::PopAndDestroy();	// close stream
+
+	CBufFlat* outputBuffer = CBufFlat::NewL(KBufferGranularity);
+	CleanupStack::PushL(outputBuffer);
+
+	RBufWriteStream outStream;
+	outStream.Open(*outputBuffer);
+	CleanupClosePushL(outStream);
+
+	
+	outStream.WriteUint16L(total + 4);	// 4 byte header
+	outStream.WriteUint16L(((count+1)*2)+1);
+
+	TPtr8 ptr = buffer->Ptr(0);
+	outStream.WriteL(ptr.Ptr(), ptr.Length());
+	TPtr8 indexptr = indexbuffer->Ptr(0);
+	outStream.WriteL(indexptr.Ptr(), indexptr.Length());
+	outStream.CommitL();
+	CleanupStack::PopAndDestroy();// outStream
+
+
+/* DEBUG - OUTPUT UNCOMPRESSED REPRESENTATION TO A FILE - FOR VERIFICATION */
+#ifdef __DEBUG_WRITE_UNCOMPRESSED_BAFL_RESOURCE
+	{
+	TFileName newName(aName);
+	newName.Append(_L(".ER5u"));
+
+	RFileWriteStream outStream;
+	User::LeaveIfError(outStream.Replace(aFs, newName, EFileWrite));
+	CleanupClosePushL(outStream);
+
+	
+	outStream.WriteUint16L(total + 4);	// 4 byte header
+	outStream.WriteUint16L(((count+1)*2)+1);
+
+	TPtr8 ptr = buffer->Ptr(0);
+	outStream.WriteL(ptr.Ptr(), ptr.Length());
+	TPtr8 indexptr = indexbuffer->Ptr(0);
+	outStream.WriteL(indexptr.Ptr(), indexptr.Length());
+	outStream.CommitL();
+	CleanupStack::PopAndDestroy(); // outStream
+	}
+#endif /* END __DEBUG_WRITE_UNCOMPRESSED_BAFL_RESOURCE */
+
+	iDict = new(ELeave)CDictArray();
+
+	iFileLength = outputBuffer->Size();
+
+	iResData = (TUint8*)User::AllocL(iFileLength);
+
+	Mem::Copy(iResData, const_cast<TUint8*>(outputBuffer->Ptr(0).Ptr()), iFileLength );
+
+	CleanupStack::PopAndDestroy(outputBuffer);
+
+	CleanupStack::PopAndDestroy(indexbuffer);
+	CleanupStack::PopAndDestroy(buffer);
+
+	CleanupStack::PopAndDestroy(); // res
+
+	// Need to keep original size in order to compare with new compression for IsValid()
+	TEntry entry;
+	if(	aFs.Entry(aName, entry) ==KErrNone)
+		{
+		iOriginalCompressedSize = entry.iSize;
+		}
+
+	}
+
+TBool CResComp::FileIsBAFLCompressedL(RFs& aFs, const TDesC& aFileName)
+	{
+	const TUid KBAFLCompressedFileUid = {0x101f4a6b};	// rcomp unicode compressed
+
+	TEntry entry;
+	User::LeaveIfError(aFs.Entry(aFileName,entry));
+	
+	return  entry.IsUidPresent(KBAFLCompressedFileUid);
+	}
+
+void CResComp::LoadFileL(RFs& aFs, const TDesC& aFileName)
+	{
+	ASSERT(iDict==NULL);
+
+	TParsePtrC parse(aFileName);
+	iConOutput.Format(parse.NameAndExt());
+	iConOutput.Append(_L("\t"));
+	if (parse.NameAndExt().Length() < 16)
+		{
+		iConOutput.Append(_L("\t"));
+		}
+
+	if(FileIsBAFLCompressedL(aFs, aFileName))
+		{
+		LoadBAFLCompressedFileL(aFs, aFileName);
+		}
+	else
+		{
+		LoadUnCompressedFileL(aFs, aFileName);
+		}
+	
+	}
+
+void CResComp::LoadUnCompressedFileL(RFs& aFs, const TDesC& aFileName)
+	{
+
+	iDict = new(ELeave)CDictArray();
+
+	TEntry entry;
+	User::LeaveIfError( aFs.Entry(aFileName, entry) );
+	iFileLength = entry.iSize;
+
+	iResData = (TUint8*)User::AllocL(entry.iSize + 2); // +2 for file size
+
+	RFileReadStream stream;
+	User::LeaveIfError( stream.Open(aFs, aFileName, EFileRead) );
+	CleanupClosePushL(stream);
+	stream.ReadL(iResData, entry.iSize);
+	CleanupStack::PopAndDestroy();	 // stream
+	}
+
+
+void CResComp::CompressL()
+	{
+	if (iFileLength == 0)
+		{
+		iCompressedSize = iFileLength;
+		return;
+		}
+
+	TUint16* resData16 = (TUint16*)iResData;
+	TInt indexOffset = resData16[0];
+	TInt indexLength = resData16[1];
+
+	if (indexOffset == 4)
+		{
+		// File is already compressed
+		iCompressedSize = iFileLength;
+		return;
+		}
+
+	if (indexOffset > iFileLength)
+		{
+		iCompressedSize = iFileLength;
+		return;
+		}
+
+	iResources = (indexLength / 2) - 1;
+
+//	iConsole->Printf(_L("Resources: %d\n"), iResources);
+
+//	iConOutput.AppendFormat(_L("%d\t\t"), iResources);
+
+
+	iResIndex = (TUint16*)(iResData + indexOffset);
+
+
+	iResArray = new(ELeave)CArrayPtrFlat<CResEntry>(10);
+
+	iResIndex[iResources] = (TUint16)(iFileLength-((iResources+1) * 2)); // end of file - index
+
+	// Build dictionary
+
+//	iConsole->Printf(_L("Building Dictionary\n"));
+
+	for (TInt ii=0; ii<iResources; ii++)
+		{
+		TBuf<80> lineOut(_L("\r"));
+		lineOut.Append(iConOutput);
+		lineOut.AppendFormat(_L("%3d / %3d"), ii+1, iResources);
+		iConsole->Printf(lineOut);
+//		iConsole->Printf(_L("\r%d / %d"), ii+1, iResources);
+		CResEntry* rEntry = new(ELeave)CResEntry(iDict);
+		CleanupStack::PushL(rEntry);
+
+		TInt resSize = iResIndex[ii+1] - iResIndex[ii];
+		if (resSize > iLargestResourceSize)
+			iLargestResourceSize = resSize;
+
+		rEntry->AddPlainDataL(iResData+iResIndex[ii], iResIndex[ii+1] - iResIndex[ii]);
+		iResArray->AppendL(rEntry);
+		CleanupStack::Pop();	//rEntry
+
+
+		rEntry->MatchSelfL(ii, this);
+		}
+
+	// Compress using dictionary
+
+
+//	iConsole->Printf(_L("\nCompressing\n"));
+
+	CDictArray* backupDict = iDict->DuplicateL();
+	CleanupStack::PushL(backupDict);
+
+	AttemptCompressionL(32);
+	iDict = backupDict->DuplicateL();
+	AttemptCompressionL(64);
+	iDict = backupDict->DuplicateL();
+	AttemptCompressionL(128);
+	iDict = backupDict->DuplicateL();
+	AttemptCompressionL(256);
+	iDict = backupDict->DuplicateL();
+	AttemptCompressionL(512);
+	iDict = backupDict->DuplicateL();
+
+
+	CompressResourcesL(iBestCompression);
+
+
+	CleanupStack::PopAndDestroy();	// backupDict
+	}
+
+TInt CResComp::AttemptCompressionL(TInt aDictEntries)
+	{
+	TInt size = CompressResourcesL(aDictEntries);
+//	RDebug::Print(_L("Entries: %d  Size:%d"), aDictEntries, size);
+
+	TBool valid = IsValid();
+	if (!valid)
+		{
+		RDebug::Print(_L("Compression Not Valid"));
+		}
+
+	if ((size < iBestSize || iBestSize == 0) && valid)
+		{
+		iBestCompression = aDictEntries;
+		iBestSize = size;
+		}
+	delete iDict;
+    iDict = NULL;
+	return size;
+	}
+
+
+TInt CResComp::CompressResourcesL(TInt aDictEntries)
+	{
+	iMaxEntries = aDictEntries;
+	iBitsForDict = 0;
+	while ( (1<<iBitsForDict) < aDictEntries)
+		{
+		iBitsForDict++;
+		}
+	iDict->iDictionaryBits = iBitsForDict;
+//	RDebug::Print(_L("Entries: %d  Bits: %d"), aDictEntries, iBitsForDict);
+	iResArray->ResetAndDestroy();
+	// Reset dictionary count
+
+	TInt dCount = iDict->Count();
+	for (TInt ll=0; ll<dCount; ll++)
+		{
+		iDict->At(ll).iUses = 0;
+		}
+
+	for (TInt kk=0; kk<iResources; kk++)
+		{
+		CResEntry* rEntry = new(ELeave)CResEntry(iDict);
+		CleanupStack::PushL(rEntry);
+		rEntry->AddPlainDataL(iResData+iResIndex[kk], iResIndex[kk+1] - iResIndex[kk]);
+		rEntry->MatchDictL();
+		iResArray->AppendL(rEntry);
+		CleanupStack::Pop();	// rEntry
+	}
+
+
+	// Optimize Dictionary
+
+	OptimizeDict();
+
+	// Compress using optimized dictionary
+
+	dCount = iDict->Count();
+	for (TInt x=0; x<dCount; x++)
+		{
+		iDict->At(x).iUses = 0;
+		}
+
+	iResArray->ResetAndDestroy();
+	for (TInt xx=0; xx<iResources; xx++)
+		{
+		CResEntry* rEntry = new(ELeave)CResEntry(iDict);
+		CleanupStack::PushL(rEntry);
+		rEntry->AddPlainDataL(iResData+iResIndex[xx], iResIndex[xx+1] - iResIndex[xx]);
+		rEntry->MatchDictL();
+		iResArray->AppendL(rEntry);
+		CleanupStack::Pop();	// rEntry
+		}
+
+
+	// Make sure that there is no more than 256 data bytes in each resource component
+	CheckForLongDataStringsL();
+	
+	TInt size = ResourceSize();
+
+	TInt count = iResArray->Count();
+
+	size += 4;			// res header
+	size += 7;			// dict header
+	size += (count + 1) * 2;	// res index
+
+	TInt dSize = iDict->DictionarySize();
+
+	iCompressedSize = size+dSize;
+	return size+dSize;
+	}
+
+TInt CResComp::ResourceSize()
+	{
+	TInt resSize = 0;
+	if (!iResArray)
+		return -1;
+	TInt count = iResArray->Count();
+	for (TInt jj=0; jj<count; jj++)
+		{
+		resSize += ((iResArray->At(jj))->Size(iBitsForDict));
+		}
+	resSize = (resSize + 7) / 8;
+	return resSize;
+	}
+
+
+
+
+TBool CResComp::IsValid()
+	{
+	TInt resSize = ResourceSize();
+	TInt dSize = iDict->DictionarySizeWithoutIndex();
+
+	RDebug::Print(_L("Ressize = %D, dsize=%D, compressedsize=%D , fileSize=%D\n"), resSize, dSize, CompressedSize(), OriginalFileSize());
+
+	if (resSize < 8192 && dSize < 8192 && (CompressedSize() < OriginalFileSize()) && resSize > 0)
+		{
+		return ETrue;
+		}
+	return EFalse;
+	}
+
+
+
+
+
+
+
+
+void CResComp::WriteFileL(RFs& aFs, const TDesC& aName)
+	{
+	CBufFlat* buffer = CBufFlat::NewL(1024);
+	CleanupStack::PushL(buffer);
+
+	RBufWriteStream bStream;
+	bStream.Open(*buffer);
+	CleanupClosePushL(bStream);
+
+
+	RFileWriteStream fStream;
+	User::LeaveIfError(fStream.Replace(aFs, aName, EFileWrite));
+
+	WriteHeaderL(fStream);
+	WriteDictionaryL(fStream);
+	WriteResourceL(fStream);
+
+	fStream.Close();
+
+	CleanupStack::PopAndDestroy(2);	// bStream, buffer
+	}
+
+
+
+void CResComp::OptimizeDict()
+	{
+	// Find referenced dicts
+	TInt entries = iDict->Count();
+
+	for (TInt ii=0; ii<entries-1; ii++)
+		{		
+		TBuf8<KMaxDictEntry> dc;
+		dc.Copy(iDict->At(ii).iData);
+
+		FindEmbeddedDict(dc, ii+1);
+		}
+
+	// Sort dictionary in order of use
+
+	CDictArray* newDict = new(ELeave)CDictArray();
+	CleanupStack::PushL(newDict);
+
+	for (TInt jj=0; jj<entries; jj++)
+		{
+		newDict->OrderedInsertL(iDict->At(jj));
+		}
+
+	TInt newDictEntries = newDict->Count();
+	if (newDictEntries > iMaxEntries)
+		newDictEntries = iMaxEntries;
+
+	iDict->Reset();
+
+	for (TInt kk=0; kk<newDictEntries; kk++)
+		{
+		iDict->SizedInsertL(newDict->At(kk));
+		}
+
+	CleanupStack::PopAndDestroy();	// newDict
+
+	for (TInt zz=0; zz<newDictEntries; zz++)
+		{
+		iDict->At(zz).CreateEmbeddedDict(zz, iDict);
+		}
+	}
+
+
+void CResComp::FindEmbeddedDict(TDesC8& aMatch, TInt aStart)
+	{
+	TInt entries = iDict->Count();
+	for (TInt ii=aStart; ii<entries; ii++)
+		{
+		TInt found = aMatch.Find(iDict->At(ii).iData);
+		if (found != KErrNotFound)
+			{
+			// Found embedded dict
+			iDict->At(ii).iRef++;
+			if (found > 1)
+				{
+				TPtrC8 left = aMatch.Left(found);
+				FindEmbeddedDict(left, ii);
+				}
+			TInt right = aMatch.Length() - iDict->At(ii).iData.Length() - found;
+			if (right > 1)
+				{
+				TPtrC8 rt = aMatch.Right(right);
+				FindEmbeddedDict(rt, ii);
+				}
+			break;
+			}
+		}
+	}
+
+
+TPtrC8 CResComp::Resource(TInt aRes)
+	{
+	return TPtrC8(iResData+iResIndex[aRes], iResIndex[aRes+1] - iResIndex[aRes]);
+	}
+
+
+TInt CResComp::FindInResources(TDesC8& aBuf, TInt aMax)
+	{
+	TInt result = KErrNotFound;
+	for (TInt ii=0; ii<aMax; ii++)
+		{
+		TPtrC8 res = Resource(ii);
+		TInt found = res.Find(aBuf);
+		if (found != KErrNotFound)
+			return ii;
+		}
+	return result;
+	}
+
+
+
+
+void CResComp::WriteHeaderL(RWriteStream& aStream)
+	{
+	// Write resource header
+
+	aStream.WriteInt16L(4);	// position of dictionary data
+	aStream.WriteInt16L(iResources);
+	}
+
+
+void CResComp::WriteDictionaryL(RWriteStream& aStream)
+	{
+	WriteDictionaryHeaderL(aStream);
+	WriteDictionaryIndexL(aStream);
+	WriteDictionaryDataL(aStream);
+	}
+
+void CResComp::WriteDictionaryHeaderL(RWriteStream& aStream)
+	{
+/*	Dictionary header format
+
+	Offset	Length(bytes)	Data
+	0		1				Version number
+	1		1				Number of dictionary items
+	2		2				File offset of resource index
+	4		2				Size of largest resource
+
+//	2		2				File offset of dictionary
+//	6		2				File offset of resource data
+*/
+	aStream.WriteUint8L(1);	// used to define different compression methods
+	TInt dictSize = iDict->Count();
+	TInt diff = (1 << iBitsForDict) - dictSize;
+	aStream.WriteUint8L(diff);
+	TInt headerSize = 4 + 7;
+	TInt resourceIndex = headerSize + iDict->DictionarySize();
+//	TInt resourceData = resourceIndex + (iResources	* 2);
+	aStream.WriteUint16L(resourceIndex);
+	aStream.WriteUint16L(iLargestResourceSize);
+//	RDebug::Print(_L("ResourceIndex:%d bytes"), resourceIndex);
+	aStream.WriteUint8L(iBitsForDict);
+	}
+
+void CResComp::WriteDictionaryIndexL(RWriteStream& aStream)
+	{
+	// Write bitIndex of each dictionary element
+	// (as offset from start of dictionaryData)
+	TInt dSize = iDict->Count();
+	TInt offset = 0;
+	aStream.WriteUint16L(0);
+	for (TInt ii=0; ii<dSize; ii++)
+		{
+		offset += iDict->BitSize(ii);
+		aStream.WriteUint16L(offset);
+		}
+	}
+
+void CResComp::WriteDictionaryDataL(RWriteStream& aStream)
+	{
+	TBitWriter bitWrite(aStream);
+	TInt dSize = iDict->Count();
+	for (TInt ii=0; ii<dSize; ii++)
+		{
+		iDict->WriteBitStreamL(ii, bitWrite);
+		}
+	bitWrite.FlushL();
+	}
+
+
+
+void CResComp::WriteResourceL(RWriteStream& aStream)
+	{
+	WriteResourceIndexL(aStream);
+	WriteResourceDataL(aStream);
+	}
+
+void CResComp::WriteResourceIndexL(RWriteStream& aStream)
+	{
+	// Write bitIndex of each resource element
+	// (as offset from start of resource Index)
+	TInt offset = 0;
+	aStream.WriteUint16L(0);
+	for (TInt ii=0; ii<iResources; ii++)
+		{
+		offset += ((iResArray->At(ii))->Size(iBitsForDict));
+		aStream.WriteUint16L(offset);
+		}
+	}
+
+void CResComp::WriteResourceDataL(RWriteStream& aStream)
+	{
+//	RDebug::Print(_L("Writing Resource Data"));
+	TBitWriter bitWrite(aStream);
+	for (TInt ii=0; ii<iResources; ii++)
+		{
+//		RDebug::Print(_L("Writing Resource %d"), ii);
+		(iResArray->At(ii))->WriteBitStreamL(bitWrite,iBitsForDict);
+		}
+	bitWrite.FlushL();
+	}
+
+
+
+TInt CResComp::OriginalFileSize()
+	{
+	if(iOriginalCompressedSize)
+		return iOriginalCompressedSize;
+	else
+		return iFileLength;
+	}
+
+TInt CResComp::CompressedSize()
+	{
+	return iCompressedSize;
+	}
+
+void CResComp::DisplayStats()
+	{
+	TInt size = 0;
+	TInt rsize = 0;
+	TInt count = iResArray->Count();
+
+	for (TInt jj=0; jj<count; jj++)
+		{
+		rsize += ((iResArray->At(jj))->Size(iBitsForDict));// + 7) / 8;
+		}
+
+	rsize = (rsize + 7) / 8;
+
+	size += 4;			// res header
+	size += 7;			// dict header
+	size += (count + 1) * 2;	// res index
+
+	size += rsize;
+	TInt dSize = iDict->DictionarySize();
+
+//	iConsole->Printf(_L("Original Size: %d bytes\n"), iFileLength);
+//	iConsole->Printf(_L("Compressed Resource Size: %d bytes\n"), size);
+//	iConsole->Printf(_L("Compressed Dictionary Size: %d bytes\n"), dSize);
+//	iConsole->Printf(_L("Compressed Size: %d bytes\n"), size+dSize);
+//	iConsole->Printf(_L("Dictionary Size: %d \n"), iDict->Count());
+
+	TInt compression = ((size + dSize) * 100) / iFileLength;
+//	iConsole->Printf(_L("Compression = %d %%\n"), compression);
+
+
+	iConsole->Printf(_L("\t%d\t%d\t%d\t%d %%\t%d\n"), iFileLength, size+dSize, compression,iOriginalCompressedSize, 1<<iBitsForDict);
+
+	TInt bitsForDictIndex = 0;
+	while ( (1<<bitsForDictIndex) < dSize)
+		{
+		bitsForDictIndex++;
+		}
+	TInt bitsSaved = iDict->Count() * (16 - bitsForDictIndex);
+	bitsSaved = (bitsSaved + 7) / 8;
+//	RDebug::Print(_L("Possible saving for dictionary: %d"), bitsSaved);
+
+	TInt bitsForResIndex = 0;
+	while ( (1<<bitsForResIndex) < rsize)
+		{
+		bitsForResIndex++;
+		}
+	TInt rbitsSaved = count * (16 - bitsForResIndex);
+	rbitsSaved = (rbitsSaved + 7) / 8;
+//	RDebug::Print(_L("Possible saving for res: %d"), rbitsSaved);
+
+//	RDebug::Print(_L("Total Compressed Size: %d  Possible: %d"), size+dSize, (size+dSize) - (bitsSaved+rbitsSaved));
+	}
+
+
+
+// Check that none of the data lengths exceed 256 bytes.
+
+void CResComp::CheckForLongDataStringsL()
+	{
+	RDebug::Print(_L("CheckingForLongDataStrings"));
+	for (TInt ii=0; ii<iResources; ii++)
+		{
+		RDebug::Print(_L("Checking Resource %d"), ii);
+		(iResArray->At(ii))->CheckForLongDataStringsL();
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/src/resdict.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,204 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+#include <e32svr.h>
+
+#include "resdict.h"
+#include "resentry.h"
+
+// TDictEntry
+
+TDictEntry::TDictEntry()
+	{
+	iUses = 0;
+	iRef = 0;
+	iEmbedded = 0;
+	}
+
+void TDictEntry::Close()
+	{
+	delete iEmbedded;
+	iEmbedded = NULL;
+	}
+
+
+
+TDesC8& TDictEntry::Data()
+	{
+	return iData;
+	}
+
+TInt TDictEntry::Use()
+	{
+	return ((iUses + iRef - 1) * (Data().Length()-1));
+	}
+
+
+void TDictEntry::CreateEmbeddedDict(TInt aDictIndex,CDictArray* aDict)
+	{
+	// Create list of embedded dictionary strings
+	iEmbedded = new(ELeave)CResEntry(aDict);
+	iEmbedded->AddPlainDataL((TUint8*)iData.Ptr(), iData.Length());
+	iEmbedded->MatchDictL(aDictIndex);
+	}
+
+
+// CDictArray
+
+CDictArray::CDictArray()
+:CArrayFixFlat<TDictEntry>(10)
+	{
+	}
+
+CDictArray::~CDictArray()
+	{
+	TInt count = Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		At(ii).Close();
+		}
+	}
+
+
+TInt CDictArray::AddEntryL(TDesC8& aEntry)
+	{
+	TInt size = aEntry.Size();
+	TInt pos = 0;
+	TInt count = Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TInt dSize = At(ii).Data().Size();
+		if (dSize < size)
+			{
+			break;
+			}
+		else
+			{
+			if (At(ii).Data().Compare(aEntry) == 0)
+				{
+				// Already in dict
+				return ii;
+				}
+			pos++;
+			}
+		}
+	TDictEntry entry;
+	entry.iData = aEntry;
+	entry.iUses=0;
+	InsertL(pos, entry);
+	return pos;
+	}
+
+
+void CDictArray::OrderedInsertL(TDictEntry& aEntry)
+	{
+	TInt use = aEntry.Use();
+	if (use < 1)
+		return;	 // Don't bother to insert entries that aren't used
+
+	TInt count = Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TInt entryUse = At(ii).Use();
+		if (entryUse < use)
+			{
+			InsertL(ii, aEntry);
+			return;
+			}
+		}
+	AppendL(aEntry);
+	}
+
+void CDictArray::SizedInsertL(TDictEntry& aEntry)
+	{
+	TInt len = aEntry.Data().Length();
+
+	TInt count = Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TInt entryLen = At(ii).Data().Length();
+		if (entryLen < len)
+			{
+			InsertL(ii, aEntry);
+			return;
+			}
+		}
+	AppendL(aEntry);
+	}
+
+TInt CDictArray::DictionarySize()
+	{
+	TInt count = Count();
+	TInt size = 0;
+	for (TInt jj=0; jj<count; jj++)
+		{
+		size += At(jj).iEmbedded->Size(iDictionaryBits);
+		}
+
+	size = (size + 7) / 8;
+
+	// Add dictionary index
+	size += (count * 2);
+
+	// Add dictionary header
+
+	size += 2;
+
+	return size;
+	}
+
+TInt CDictArray::DictionarySizeWithoutIndex()
+	{
+	TInt count = Count();
+	TInt size = 0;
+	for (TInt jj=0; jj<count; jj++)
+		{
+		size += At(jj).iEmbedded->Size(iDictionaryBits);
+		}
+	size = (size + 7) / 8;
+	return size;
+	}
+
+
+
+TInt CDictArray::BitSize(TInt aIndex)
+	{
+	return At(aIndex).iEmbedded->Size(iDictionaryBits);
+	}
+
+
+void CDictArray::WriteBitStreamL(TInt aIndex, TBitWriter& aWriter)
+	{
+	RDebug::Print(_L("Dictionary Entry: %d"), aIndex);
+	At(aIndex).iEmbedded->WriteBitStreamL(aWriter,iDictionaryBits);
+	}
+
+
+
+CDictArray* CDictArray::DuplicateL()
+	{
+	CDictArray* newDict = new(ELeave)CDictArray();
+	CleanupStack::PushL(newDict);
+	TInt count = Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		newDict->AppendL(At(ii));
+		}
+	CleanupStack::Pop();	// newDict;
+	return newDict;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reszip/src/resentry.cpp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,502 @@
+/*
+* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+
+#include "resentry.h"
+#include "resdict.h"
+#include "rescomp.h"
+
+//TResComponent
+
+TInt TResComponent::Size(TInt aDictionaryBits)
+	{
+	if (iType == EResTypePlain)
+		{
+		if (iLength == 0)
+			return 0;
+		TInt bits = iLength * 8;
+		bits++;			// data flag
+		if (iLength == 1)
+			bits ++;	// first bit zero if 1 byte of data
+		else 
+			{
+			bits++;		// first bit 1 if >1 byte of data
+			if (iLength == 2)
+				{
+				bits ++;	// second bit zero if 2 bytes of data
+				}
+			else
+				{
+				bits ++;		// second bit 1 if >2 bytes of data
+				if (iLength < 11)
+					{
+					// write 4 bits of data + 1 zero bit flag
+					bits += 4;
+					}
+				else
+					{
+					// write 8 bits of data + 1 '1' bit flag
+					bits += 9;
+					}
+				}
+			}
+
+//		console->Printf(_L("Type Plain: %d\n"), bits);
+		return bits;
+		}
+	if (iType == EResTypeToken)
+		{
+		return 1+aDictionaryBits;
+//		console->Printf(_L("Type Token: %d\n"), iToken);
+//		return 8;		// dictionary entries are stored in 6 bits
+		}
+	return 0;
+	}
+
+
+void TResComponent::WriteBitStreamL(TBitWriter& aWriter, TInt aDictionaryBits)
+	{
+	if (iType == EResTypePlain)
+		{
+		if (iLength == 0)
+			return;
+// Debugging code
+/*
+		RDebug::Print(_L("Data Length: %d"), iLength);
+		TBuf<100> b;
+		for (TInt xx=0; xx<iLength; xx++)
+			{
+			b.AppendFormat(_L("%02x "), iData[xx]);
+			}
+		RDebug::Print(b);
+*/
+//
+		// Write 'data' flag
+		aWriter.WriteL(1, 1);
+		if (iLength == 1)
+			{
+			aWriter.WriteL(0, 1); // first bit zero if 1 byte of data
+			}
+		else 
+			{
+			aWriter.WriteL(1, 1);		// first bit 1 if >1 byte of data
+			if (iLength == 2)
+				{
+				aWriter.WriteL(0, 1); // second bit zero if 2 bytes of data
+				}
+			else
+				{
+				aWriter.WriteL(1, 1); // second bit 1 if >2 bytes of data
+				if (iLength < 11)
+					{
+					aWriter.WriteL(0, 1);
+					aWriter.WriteL(iLength-3, 3);
+					// write 4 bits of data + 1 zero bit flag
+					}
+				else
+					{
+					aWriter.WriteL(1, 1);
+					aWriter.WriteL(iLength, 8);
+					// write 8 bits of data + 1 '1' bit flag
+					if (iLength > 255)
+						{
+						User::Panic(_L("Entry too long"),0);
+						}
+					}
+				}
+			}
+		// Now write data to output
+		for (TInt ii=0; ii<iLength; ii++)
+			{
+			aWriter.WriteL(iData[ii], 8);
+			}
+		}
+	if (iType == EResTypeToken)
+		{
+		// Write 'token' flag
+		aWriter.WriteL(0, 1);
+
+		// Write token
+		aWriter.WriteL(iToken, aDictionaryBits);
+//		RDebug::Print(_L("Token [%d] "), iToken);
+		}
+	}
+
+
+
+// CResEntry
+CResEntry::CResEntry(CDictArray* aDict)
+:iDict(aDict)
+	{
+	iComponent = new(ELeave)CArrayFixFlat<TResComponent>(4);
+	}
+
+CResEntry::~CResEntry()
+	{
+	delete iComponent;
+	}
+
+
+void CResEntry::AddPlainDataL(TUint8* aData, TInt aLength)
+	{
+	TResComponent comp;
+	comp.iType = EResTypePlain;
+	comp.iData = aData;
+	comp.iLength = aLength;
+	iComponent->AppendL(comp);
+	}
+
+void CResEntry::InsertTokenL(TInt aPosition, TInt aToken)
+	{
+	TResComponent comp;
+	comp.iType = EResTypeToken;
+	comp.iToken = aToken;
+	comp.iLength=0;
+	iComponent->InsertL(aPosition,comp);
+	(*iDict)[aToken].iUses++;
+	}
+
+void CResEntry::SplitPlainDataWithZeroSpacedL(TInt aComponent, TInt aZeroSpacedStart, TInt aLength)
+	{
+	TResComponent comp = (*iComponent)[aComponent];
+
+	TResComponent newComp1;
+	newComp1.iType = EResTypePlain;
+	newComp1.iData = comp.iData;
+	newComp1.iLength = aZeroSpacedStart;
+
+	TResComponent newComp2;
+	newComp2.iType = EResTypePlain;
+	newComp2.iData = comp.iData + aZeroSpacedStart + aLength;
+	newComp2.iLength = comp.iLength-(aZeroSpacedStart+aLength);
+
+	TResComponent newComp3;
+	newComp3.iType = EResTypeZeroSpaced;
+	newComp3.iData = comp.iData + aZeroSpacedStart;
+	newComp3.iLength = aLength;
+
+
+	iComponent->Delete(aComponent);
+	TInt componentPos = aComponent;
+    if (newComp1.iLength != 0)
+		{
+		iComponent->InsertL(componentPos, newComp1);
+		componentPos++;
+		}
+
+	iComponent->InsertL(componentPos, newComp3);
+	componentPos++;
+
+	if (newComp2.iLength != 0)
+		{
+		iComponent->InsertL(componentPos, newComp2);
+		}
+	}
+
+
+void CResEntry::SplitPlainDataWithTokenL(TInt aComponent, TInt aToken, TInt aPosition)
+	{
+	TResComponent comp = (*iComponent)[aComponent];
+	TDesC8& dEntry = (*iDict)[aToken].Data();
+	TInt dictLength = dEntry.Length();
+
+	TResComponent newComp1;
+	newComp1.iType = EResTypePlain;
+	newComp1.iData = comp.iData;
+	newComp1.iLength = aPosition;
+
+	TResComponent newComp2;
+	newComp2.iType = EResTypePlain;
+	newComp2.iData = comp.iData + aPosition + dictLength;
+	newComp2.iLength = comp.iLength - dictLength - aPosition;
+
+	iComponent->Delete(aComponent);
+	TInt componentPos = aComponent;
+    if (newComp1.iLength != 0)
+		{
+		iComponent->InsertL(componentPos, newComp1);
+		componentPos++;
+		}
+	InsertTokenL(componentPos, aToken);
+	componentPos++;
+
+	if (newComp2.iLength != 0)
+		{
+		iComponent->InsertL(componentPos, newComp2);
+		}
+
+	}
+
+
+TInt CResEntry::Size(TInt aDictionaryBits)
+	{
+	TInt size = 0;
+	TInt count = iComponent->Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		size += iComponent->At(ii).Size(aDictionaryBits);
+		}
+	return size;
+	}
+
+void CResEntry::WriteBitStreamL(TBitWriter& aWriter, TInt aDictionaryBits)
+	{
+	TInt count = iComponent->Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		iComponent->At(ii).WriteBitStreamL(aWriter, aDictionaryBits);
+		}
+	}
+
+
+
+TBool CResEntry::DoMatchDictL(TResComponent& aComp, TInt aOffset, TInt aDictIndex)
+	{
+	TInt dCount = iDict->Count();
+	TInt cSize = aComp.iLength;
+	for (TInt ii=0; ii<dCount; ii++)
+		{
+		if (ii != aDictIndex)
+			{
+			TDesC8& dEntry = (*iDict)[ii].Data();
+			if (dEntry.Length() <= cSize)
+				{
+				TPtrC8 data(aComp.iData, cSize);
+				TInt pos = data.Find(dEntry);
+				if (pos != KErrNotFound)
+					{
+//					console->Printf(_L("Found %d Offset: %d\n"),ii, pos);
+					SplitPlainDataWithTokenL(aOffset, ii, pos);
+					return ETrue;
+				}
+			}
+			}
+		}
+	return EFalse;
+	}
+
+
+void CResEntry::MatchDictL(TInt aDictIndex)
+	{
+	// Match plain text components against dictionary
+	TInt count = iComponent->Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TResComponent comp = (*iComponent)[ii];
+		if (comp.iType == EResTypePlain)
+			{
+			if (DoMatchDictL(comp, ii, aDictIndex))
+				{
+				count = iComponent->Count();
+				ii--;
+				}
+			}
+		}
+	}
+
+
+/*
+void CResEntry::MatchZeroSpacedL()
+	{
+	// Find zero spaced data
+	TInt count = iComponent->Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TResComponent comp = (*iComponent)[ii];
+		if (comp.iType == EResTypePlain)
+			{
+			if (DoMatchZeroSpacedL(comp, ii))
+				{
+				count = iComponent->Count();
+				ii--;
+				}
+			}
+		}
+	}
+
+
+TBool CResEntry::DoMatchZeroSpacedL(TResComponent& aComp, TInt aOffset)
+	{
+	// Analyse data and see if there is a string of zero spaced data
+	// Data, followed by zero
+	TInt length = aComp.iLength;
+	TInt pos = 0;
+	TInt dataSize = 0;
+	for (TInt ii=0; ii<length-1; ii++)
+		{
+		if (aComp.iData[ii+1] == 0)
+			{
+			// Found zero spaced data
+			if (dataSize == 0)
+				{
+				// Start of zero spaced data
+				pos = ii;
+				dataSize = 2;
+				}
+			else
+				{
+				dataSize += 2;
+				}
+			ii++;
+			}
+		else
+			{
+			// End of zero spaced data
+			if (dataSize > 2)
+				{
+				SplitPlainDataWithZeroSpacedL(aOffset, pos, dataSize);
+				return ETrue;
+				}
+			dataSize = 0;
+			}
+		}
+	return EFalse;
+	}
+*/
+
+
+void CResEntry::MatchSelfL(TInt aRes,CResComp* aResComp)
+	{
+	// Find duplicates within resource
+	TInt count = iComponent->Count();
+	for (TInt ii=0; ii<count; ii++)
+		{
+		TResComponent comp = (*iComponent)[ii];
+		if (comp.iType == EResTypePlain)
+			{
+			if (DoMatchSelfL(comp, ii, aRes, aResComp))
+				{
+				count = iComponent->Count();
+				ii--;
+				}
+			}
+		}
+	}
+
+
+
+
+/*
+TBool CResEntry::MatchPreviousComponent(TInt aCompIndex, TDesC8& aMatch)
+	{
+	TInt size = aMatch.Size();
+	for (TInt ii=0; ii<aCompIndex; ii++)
+		{
+		TResComponent comp = (*iComponent)[ii];
+		if (comp.iType == EResTypePlain)
+			{
+			console->Printf(_L("Matching: %d (Length: %d)\n"), aCompIndex, size);
+			if (comp.iLength <= size)
+				{
+				 TPtrC8 buf(comp.iData, comp.iLength);
+				 TInt found = buf.Find(aMatch);
+				 if (found != KErrNotFound)
+					 {
+					 console->Printf(_L("Found\n"));
+					 return ii;
+					 }
+				}
+			}
+		}
+
+	return KErrNotFound;
+	}
+*/
+
+TBool CResEntry::DoMatchSelfL(TResComponent& aComp, TInt aOffset, TInt aRes, CResComp* aResComp)
+	{
+	TInt cSize = aComp.iLength;
+	TInt matchSize = cSize/2;
+	if (matchSize > KMaxDictEntry)
+		matchSize = KMaxDictEntry;
+
+	while (matchSize > 1)
+		{
+		TInt pos=matchSize;
+		TInt positions = (cSize-(matchSize*2))+1;
+		while (positions)
+			{
+			TPtr8 match(aComp.iData + pos, matchSize,matchSize);
+			TPtr8 left(aComp.iData, pos, pos);
+			TInt found = left.Find(match);
+			if (found != KErrNotFound)
+				{
+				TInt token = iDict->AddEntryL(match);
+				// Remove both matches and replace with token
+				SplitPlainDataWithTokenL(aOffset, token, pos);
+				SplitPlainDataWithTokenL(aOffset, token, found);
+				return ETrue;
+				}
+			else
+				{
+				// Find in all other resources
+				TInt find = aResComp->FindInResources(match, aRes);
+				if (find != KErrNotFound)
+					{
+					TInt token = iDict->AddEntryL(match);
+					SplitPlainDataWithTokenL(aOffset, token, pos);
+					return ETrue;
+					}
+
+				}
+			positions--;
+			pos++;
+			}
+		matchSize--;
+		}
+	return EFalse;
+	}
+
+
+	TResType iType;
+	TUint8* iData;
+	TInt iLength;
+	TInt iToken;
+
+
+void CResEntry::CheckForLongDataStringsL()
+	{
+	TInt components = iComponent->Count();
+	for (TInt ii=0; ii<components; ii++)
+		{
+		TResComponent comp = (*iComponent)[ii];
+		if (comp.iLength > 255)
+			{
+			TInt length = comp.iLength;
+			RDebug::Print(_L("Component Too Long!"));
+			TResComponent comp1;
+			comp1.iType = comp.iType;
+			comp1.iData = comp.iData;
+			comp1.iLength = 255;
+			comp1.iToken = comp.iToken;
+
+			TResComponent comp2;
+			comp2.iType = comp.iType;
+			comp2.iData = comp.iData + 255;
+			comp2.iLength = length - 255;
+			comp2.iToken = comp.iToken;
+
+			iComponent->Delete(ii);
+			iComponent->InsertL(ii, comp1);
+			iComponent->InsertL(ii+1, comp2);
+
+			components = iComponent->Count();
+			}
+		}
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/skincompiler/AknSkinDescCompiler/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  ?Description
+*
+*/
+
+
+PRJ_PLATFORMS
+TOOLS
+
+PRJ_MMPFILES
+// ==== REMOVED ====
+// Compiler is now built in AknSkins
+// ==== REMOVED ====
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/skincompiler/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,18 @@
+/*
+* 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 "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:
+*
+*/
+
+#include "../AknSkinDescCompiler/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* 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 "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:  Highlevel bld.inf
+*
+*/
+
+
+
+#include "../svgtenc/standalone/group/bld.inf"
+
+PRJ_PLATFORMS
+DEFAULT TOOLS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/SVGEncoder_CPP.dsp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,1107 @@
+# Microsoft Developer Studio Project File - Name="SVGEncoder_CPP" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=SVGEncoder_CPP - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "SVGEncoder_CPP.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "SVGEncoder_CPP.mak" CFG="SVGEncoder_CPP - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "SVGEncoder_CPP - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "SVGEncoder_CPP - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "SVGEncoder_CPP - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /I "..\Internal\SVGEngine\inc" /I "..\Internal\Gfx2D\inc" /I "..\Internal\Gfx2D\VGRasterizer\inc" /I "..\Internal\Xmldomimpl\inc" /I "..\Internal\SVGImpl\inc\SVGDOM" /I "..\Internal\SVGImpl\inc" /I "..\xerces-c-src_2_6_0" /I "..\Internal\Path\inc" /I "..\Internal\xmlReader\inc" /I "..\Internal\Sax2Print" /I "..\Internal\Nvg\inc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /D /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 symdefcppdll.lib xerces-c_2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMT" /nodefaultlib:"MSVCRTD" /out:"Release/SVGTBINENCODE.exe" /libpath:"..\Internal\lib"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF  "$(CFG)" == "SVGEncoder_CPP - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\Internal\SVGEngine\inc" /I "..\Internal\Gfx2D\inc" /I "..\Internal\Gfx2D\VGRasterizer\inc" /I "..\Internal\Xmldomimpl\inc" /I "..\Internal\SVGImpl\inc\SVGDOM" /I "..\Internal\SVGImpl\inc" /I "..\xerces-c-src_2_6_0" /I "..\Internal\Path\inc" /I "..\Internal\xmlReader\inc" /I "..\Internal\Sax2Print" /I "..\Internal\Nvg\inc" /I "C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ARM" /FR /YX /FD /D /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo /o"Debug/SVGTBINENCODE.bsc"
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib xerces-c_2.lib symdefcppdll.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/SVGTBINENCODE.exe" /pdbtype:sept /libpath:"..\lib"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF 
+
+# Begin Target
+
+# Name "SVGEncoder_CPP - Win32 Release"
+# Name "SVGEncoder_CPP - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxAffineTransform.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGc\GfxColor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxEllipse2D.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxEllipseIteratorP.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxFlatteningPathIterator.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxFloatFixPt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxGeneralPath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxGeneralPathIteratorP.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGc\GfxGradientPaint.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxLine2D.cpp
+
+!IF  "$(CFG)" == "SVGEncoder_CPP - Win32 Release"
+
+!ELSEIF  "$(CFG)" == "SVGEncoder_CPP - Win32 Debug"
+
+# ADD CPP /w /W0
+# SUBTRACT CPP /O<none>
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxLineIteratorP.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxPoint2D.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxRectangle2D.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxRectangleIteratorP.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxRectangularShape.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxRoundRectangle2D.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\GfxGeom\GfxRoundRectangleIteratorP.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\src\Gfxtrignometric.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\xmlReader\src\MyRXMLReader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGCircleElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NvgCommandSection.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGDefElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGElementFactory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGEllipseElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGEncoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGGElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NvgHeaderSection.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGLinearGradientElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGLineElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NvgOffsetVector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NvgPaintSection.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGPathElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NvgPathSection.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGPolygonElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGRadialGradientElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGRectElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGStopElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\src\NVGSVGElement.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Sax2Print\SAX2PrintHandlers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimateElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimateMotionElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimateTransformElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimationBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimTimeController.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAnimTimingParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\src\svgapi.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGAttributeVerifier.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGAudioElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGCircleElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGClrCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGColor.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGContentHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGDiscardElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGDocumentImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGDOMImplementationImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGEllipseElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\Svgencoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\Svgencodermain.cpp
+
+!IF  "$(CFG)" == "SVGEncoder_CPP - Win32 Release"
+
+# ADD CPP /ZI /FAcs
+
+!ELSEIF  "$(CFG)" == "SVGEncoder_CPP - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGEngineImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGErrorImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGEvent.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGFitToViewBoxImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGFloatCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGFontElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGFontFaceElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGFontMap.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGGElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGGlyphElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGGradientElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SvgHkernelementimpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGImageElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGIntCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGLangSpaceImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGLinearGradientElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGLineElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\src\svgmath.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGMediaAnimationElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGMediaElementBase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGMissingGlyphElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGMpathElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPaintCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\src\svgpath.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPathDataParser.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPathElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPointLexer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPolylineElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGPreserveAspectRatioImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGRadialGradientElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGRectElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGRelToAbsPath.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGSchemaData.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGSetElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGSolidColorElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGStopElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGStrCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGStringTokenizer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGStyleElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\src\svgsubdivide.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\Svgsvgelementimpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\src\SVGTEncodeInterfaceImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGTestsImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGTextElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGTransformableImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGTransformListImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGUriReferenceImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGUseElementImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\src\SVGVectorCssValueImpl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Xmldomimpl\src\SVGXmlElementImpl.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxAffineTransform.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxColor.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxEllipse2D.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxEllipseIteratorP.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxFlatteningPathIterator.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxFloatFixPt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxFloatFixPt.inl
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxGeneralPath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxGeneralPathIteratorP.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxGradientPaint.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxLine2D.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxLineIteratorP.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxPaint.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxPathIterator.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxPoint2D.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxRectangle2D.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxRectangleIteratorP.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxRectangularShape.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxRoundRectangle2D.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxRoundRectangleIteratorP.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxShape.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\GfxStroke.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\inc\Gfxtrignometric.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Path\inc\MyUTF.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGCircleElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NvgCommandSection.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGDefElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGElementFactory.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGEllipseElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGGElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NvgHeaderSection.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGLinearGradientElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGLineElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NvgOffsetVector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NvgPaintSection.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGPathElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NvgPathSection.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGPolygonElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGRadialGradientElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGRectElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGStopElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Nvg\inc\NVGSVGElement.h
+# End Source File
+# Begin Source File
+
+SOURCE="C:\Program Files\Microsoft Visual Studio\VC98\Include\STRING.H"
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Path\inc\svg2bintype.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimateElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimateMotionElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimateTransformElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimationBase.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimTimeController.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAnimTimingParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGAttributeVerifier.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGAudioElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGCircleElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGClrCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGColor.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGContentHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGCssValue.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\inc\svgdef.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDiscardElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDocumentImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOMImplementationImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGElementTimeControl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGEllipseElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGEngineImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGErrorImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGEvent.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGEventReceiver.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGFitToViewBox.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGFitToViewBoxImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGFloatCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGFontElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGFontFaceElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGFontMap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGGElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGGlyphElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGGradientElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SvgHkernelementimpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGImageElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGIntCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGLangSpace.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGLangSpaceImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGLinearGradientElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGLineElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGLocatable.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\inc\svgmath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGMediaAnimationElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGMediaElementBase.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGMissingGlyphElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGMpathElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPaintCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPathDataParser.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPathElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPointLexer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPolylineElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGPreserveAspectRatio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGPreserveAspectRatioImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGRadialGradientElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Gfx2D\VGRasterizer\inc\svgrasterizer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGRectElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGRelToAbsPath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\SVGRequestObserver.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGSchemaData.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGSetElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGSolidColorElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SvgStopElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGStrCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGStringTokenizer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGStyleElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGSvgElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\Svgtencodeinterface.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGEngine\inc\Svgtencodeinterfaceimpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGTests.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGTestsImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGTextElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGTransformable.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGTransformableImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGTransformList.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGTransformListImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGUriReference.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGUriReferenceImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGUseElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGVectorCssValueImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Xmldomimpl\inc\SVGXmlDocument.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Xmldomimpl\inc\SVGXmlDOMImplementation.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Xmldomimpl\inc\SVGXmlElement.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Xmldomimpl\inc\SVGXmlElementImpl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGXmlElementOpt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\SVGImpl\inc\SVGDOM\SVGZoomAndPan.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Path\inc\symdef.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Path\inc\symdef.inl
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\Path\inc\symdefclass.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/SVGEncoder_CPP.dsw	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,48 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "SVGEncoder_CPP"=.\SVGEncoder_CPP.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+    Begin Project Dependency
+    Project_Dep_Name SYMDEFCPPDLL
+    End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "SYMDEFCPPDLL"=.\SYMDEFCPPDLL.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+    begin source code control
+    SYMDEFCPPDLL
+    ..\testingsymdefcppdll
+    end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/SYMDEFCPPDLL.dsp	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,257 @@
+# Microsoft Developer Studio Project File - Name="SYMDEFCPPDLL" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=SYMDEFCPPDLL - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "SYMDEFCPPDLL.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "SYMDEFCPPDLL.mak" CFG="SYMDEFCPPDLL - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "SYMDEFCPPDLL - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "SYMDEFCPPDLL - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName "SYMDEFCPPDLL"
+# PROP Scc_LocalPath "..\Internal\testingsymdefcppdll"
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 1
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYMDEFCPPDLL_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /Zi /Od /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYMDEFCPPDLL_EXPORTS" /D "_WINDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 /nologo /dll /machine:I386
+# SUBTRACT LINK32 /debug
+
+!ELSEIF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYMDEFCPPDLL_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYMDEFCPPDLL_EXPORTS" /FR /YX /FD /MLD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# SUBTRACT LINK32 /profile /pdb:none /nodefaultlib
+
+!ENDIF 
+
+# Begin Target
+
+# Name "SYMDEFCPPDLL - Win32 Release"
+# Name "SYMDEFCPPDLL - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Buf.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Des16.cpp
+
+!IF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Release"
+
+# ADD CPP /Od
+
+!ELSEIF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Des8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Desc16.cpp
+
+!IF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Release"
+
+# ADD CPP /Od
+
+!ELSEIF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Desc8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Hbufc16.cpp
+
+!IF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Release"
+
+# ADD CPP /Od
+
+!ELSEIF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Hbufc8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Rfile.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Rpointerarraybase.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tbufbase16.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tbufbase8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\TBufC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tbufcbase16.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tbufcbase8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tchar.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\TInt64.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tkeydesc8array.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tlex.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tptr16.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tptr8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tptrc16.cpp
+
+!IF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Release"
+
+# ADD CPP /Od
+
+!ELSEIF  "$(CFG)" == "SYMDEFCPPDLL - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Tptrc8.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\Trgb.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\utf.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\svg2bintype.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\symdef.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\symdef.inl
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\symdefclass.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Internal\testingsymdefcppdll\UTF.H
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:
+*
+*/
+
+
+PRJ_PLATFORMS
+
+TOOLS
+
+PRJ_EXPORTS
+../lib/SVGTBinEncode.exe	/epoc32/tools/SVGTBinEncode.exe
+../lib/xerces-c_2_6.dll		/epoc32/tools/xerces-c_2_6.dll
+PRJ_MMPFILES
+
+// Copy the SVGT Encoder Binary to target dir
+//gnumakefile copysvgtbinencode.mk
+
+// Enable Below Extension Makefile to compile and copy encoder to target dir
+//gnumakefile makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/copysvgtbinencode.mk	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,59 @@
+#
+# 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 "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:
+#
+# ======================================================================
+# Makefile to copy the standalone encoder binary to tools dir
+# ======================================================================
+
+SVGBETARGETDIR = \epoc32\tools
+
+ERASE = @erase /f 2>>nul
+
+SVGBESOURCEDIR=..\lib
+PROGRAM=SVGTBinEncode.exe
+XERCES_DLL=xerces-c_2_6.dll
+
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+
+SAVESPACE BLD : 
+		perl -S emkdir.pl $(SVGBETARGETDIR) && \
+		perl -S ecopyfile.pl $(SVGBESOURCEDIR)\$(PROGRAM) $(SVGBETARGETDIR)\$(PROGRAM) && \
+		perl -S ecopyfile.pl $(SVGBESOURCEDIR)\$(XERCES_DLL) $(SVGBETARGETDIR)\$(XERCES_DLL)
+	
+
+CLEAN : 
+	cd $(SVGBETARGETDIR) && \
+	$(ERASE) "$(PROGRAM)" && \
+	$(ERASE) "$(XERCES_DLL)"
+	
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FREEZE : do_nothing
+
+RELEASABLES : 
+	if exist $(SVGBETARGETDIR)\$(PROGRAM) echo $(SVGBETARGETDIR)\$(PROGRAM) 
+	if exist $(SVGBETARGETDIR)\$(XERCES_DLL) echo $(SVGBETARGETDIR)\$(XERCES_DLL)
+
+FINAL : do_nothing
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/makefile	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,45 @@
+#
+# Copyright (c) Symbian Software Ltd 2005.  All rights reserved.
+# 
+# Makefile for building elf2e32 executable. This can be invoked directly
+# or it can be invoked via the abld command. 
+
+export PARENT_DIR=$(CURDIR)
+
+# if the makefile is invoked via abld the build directory is defined by EPOCBLD
+ifdef EPOCBLD
+ export BUILD_DIR=$(EPOCBLD)
+else
+ export BUILD_DIR=$(EPOCROOT)epoc32\build\s60\mw\graphics\svgtopt\svgtencoder\standalone
+
+endif
+
+MAKEFILE=svgtbinencoder.mk
+DEST_MAKEFILE=$(BUILD_DIR)\$(MAKEFILE)
+
+all: $(DEST_MAKEFILE)
+	$(MAKE) -C $(BUILD_DIR) -f $(MAKEFILE) 
+	@erase /F $(DEST_MAKEFILE) 2>> nul
+
+$(DEST_MAKEFILE) : $(BUILD_DIR)
+#	echo $(DEST_MAKEFILE)
+	@copy $(MAKEFILE) $(DEST_MAKEFILE) 2>>nul
+
+$(BUILD_DIR) : 
+	@mkdir $(BUILD_DIR) 2>> nul
+
+CLEAN: $(DEST_MAKEFILE)
+	$(MAKE) -C $(BUILD_DIR) -f $(MAKEFILE) $(CFG)_clean
+	@erase /F $(DEST_MAKEFILE) 2>> nul
+
+MAKMAKE: $(DEST_MAKEFILE)
+
+BLD : $(DEST_MAKEFILE) 
+	$(MAKE) -C $(BUILD_DIR) -f $(MAKEFILE) $(CFG)
+	@erase /F $(DEST_MAKEFILE) 2>> nul
+
+FINAL: $(DEST_MAKEFILE)
+	$(MAKE) -C $(BUILD_DIR) -f $(MAKEFILE) $(CFG)_install
+	@erase /F $(DEST_MAKEFILE) 2>> nul
+
+FREEZE LIB CLEANLIB RESOURCE RELEASABLES SAVESPACE : 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svgtencoder/svgtenc/standalone/group/svgtbinencoder.mk	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,242 @@
+#
+# Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "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:
+#
+
+# It has the following dependencies on its invoking makefile
+#
+# EPOCROOT
+#
+PROGRAM=SVGTBinEncode.exe
+XERCES_DLL=xerces-c_2_6.dll
+#SYMDEFCPP_DLL=symdefcppdll.dll
+PARENT_DIR=\sf\mw\uitools\svgtencoder\svgtenc\standalone\group
+
+SOURCES_CPP=..\Internal\xmlReader\src\MyRXMLReader.cpp \
+	 ..\Internal\Sax2Print\SAX2PrintHandlers.cpp \
+	 ..\Internal\SVGEngine\src\SVGEncoderMain.cpp \
+	 ..\Internal\SVGEngine\src\SVGEngineImpl.cpp \
+	 ..\Internal\SVGEngine\src\SVGTEncodeInterfaceImpl.cpp \
+	 ..\Internal\SVGEngine\src\SVGEvent.cpp \
+	 ..\Internal\SVGEngine\src\SVGContentHandler.cpp \
+	 ..\Internal\SVGEngine\src\SVGAttributeVerifier.cpp \
+	 ..\Internal\SVGEngine\src\SVGErrorImpl.cpp \
+	 ..\Internal\SVGEngine\src\SVGEncoder.cpp \
+	 ..\Internal\svgImpl\src\SVGElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGDocumentImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGDOMImplementationImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGSolidColorElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGDiscardElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGMediaAnimationElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGMediaElementBase.cpp \
+	 ..\Internal\svgImpl\src\SVGAudioElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGSvgElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGGElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGUseElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGStyleElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGAElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGUriReferenceImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGLineElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGRectElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGCircleElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGEllipseElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGPolylineElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGPathElementImpl.cpp \
+	 ..\Internal\svgimpl\src\SVGMpathElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGTextElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGImageElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGFontElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGFontFaceElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGGlyphElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGMissingGlyphElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGHkernElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimationBase.cpp \
+	 ..\Internal\svgImpl\src\SVGSetElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimateElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimateTransformElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimateMotionElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGLinearGradientElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGGradientElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGRadialGradientElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGStopElementImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGClrCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGPaintCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGIntCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGFloatCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGStrCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGVectorCssValueImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGTransformListImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGTransformableImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGTestsImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGLangSpaceImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGFitToViewBoxImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGPreserveAspectRatioImpl.cpp \
+	 ..\Internal\svgImpl\src\SVGPointLexer.cpp \
+	 ..\Internal\svgImpl\src\SVGSchemaData.cpp \
+	 ..\Internal\svgImpl\src\SVGPathDataParser.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimTimeController.cpp \
+	 ..\Internal\svgImpl\src\SVGStringTokenizer.cpp \
+	 ..\Internal\svgImpl\src\SVGRelToAbsPath.cpp \
+	 ..\Internal\svgImpl\src\SVGAnimTimingParser.cpp \
+	 ..\Internal\svgImpl\src\SVGFontMap.cpp \
+	 ..\Internal\svgImpl\src\SVGColor.cpp \
+	 ..\Internal\XMLDOMIMPL\src\SVGXmlElementImpl.cpp \
+	 ..\Internal\gfx2d\src\GfxFloatFixPt.cpp \
+	 ..\Internal\gfx2d\src\Gfxtrignometric.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxPoint2D.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxAffineTransform.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxGeneralPath.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxGeneralPathIteratorP.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxFlatteningPathIterator.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxRectangle2D.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxRectangularShape.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxRectangleIteratorP.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxLine2D.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxLineIteratorP.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxEllipse2D.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxEllipseIteratorP.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxRoundRectangle2D.cpp \
+	 ..\Internal\gfx2d\src\GfxGeom\GfxRoundRectangleIteratorP.cpp \
+	 ..\Internal\gfx2d\src\GfxGc\GfxColor.cpp \
+	 ..\Internal\gfx2d\src\GfxGc\GfxGradientPaint.cpp \
+	 ..\Internal\testingsymdefcppdll\Buf.cpp \
+	 ..\Internal\testingsymdefcppdll\Des16.cpp \
+	 ..\Internal\testingsymdefcppdll\Des8.cpp \
+	 ..\Internal\testingsymdefcppdll\Desc16.cpp \
+	 ..\Internal\testingsymdefcppdll\Desc8.cpp \
+	 ..\Internal\testingsymdefcppdll\Hbufc16.cpp \
+	 ..\Internal\testingsymdefcppdll\Hbufc8.cpp \
+	 ..\Internal\testingsymdefcppdll\Rfile.cpp \
+	 ..\Internal\testingsymdefcppdll\Rpointerarraybase.cpp \
+	 ..\Internal\testingsymdefcppdll\Tbufbase16.cpp \
+	 ..\Internal\testingsymdefcppdll\Tbufbase8.cpp \
+	 ..\Internal\testingsymdefcppdll\TBufC.cpp \
+	 ..\Internal\testingsymdefcppdll\Tbufcbase16.cpp \
+	 ..\Internal\testingsymdefcppdll\Tbufcbase8.cpp \
+	 ..\Internal\testingsymdefcppdll\Tchar.cpp \
+	 ..\Internal\testingsymdefcppdll\TInt64.cpp \
+	 ..\Internal\testingsymdefcppdll\Tkeydesc8array.cpp \
+	 ..\Internal\testingsymdefcppdll\Tlex.cpp \
+	 ..\Internal\testingsymdefcppdll\Tptr16.cpp \
+	 ..\Internal\testingsymdefcppdll\Tptr8.cpp \
+	 ..\Internal\testingsymdefcppdll\Tptrc16.cpp \
+	 ..\Internal\testingsymdefcppdll\Tptrc8.cpp \
+	 ..\Internal\testingsymdefcppdll\Trgb.cpp \
+	 ..\Internal\testingsymdefcppdll\utf.cpp \
+	 ..\Internal\Nvg\src\NVGCircleElement.cpp \
+	 ..\Internal\Nvg\src\NvgCommandSection.cpp \
+	 ..\Internal\Nvg\src\NvgDefElement.cpp \
+	 ..\Internal\Nvg\src\NVGElement.cpp \
+	 ..\Internal\Nvg\src\NVGElementFactory.cpp \
+	 ..\Internal\Nvg\src\NVGEllipseElement.cpp \
+	 ..\Internal\Nvg\src\NVGEncoder.cpp \
+	 ..\Internal\Nvg\src\NvgHeaderSection.cpp \
+	 ..\Internal\Nvg\src\NvgOffsetVector.cpp \
+	 ..\Internal\Nvg\src\NvgPaintSection.cpp \
+	 ..\Internal\Nvg\src\NvgPathSection.cpp \
+	 ..\Internal\Nvg\src\NVGPolygonElement.cpp \
+	 ..\Internal\Nvg\src\NVGRectElement.cpp \
+	 ..\Internal\Nvg\src\NVGSVGElement.cpp \
+	 ..\Internal\Nvg\src\NVGPathElement.cpp \
+	 ..\Internal\Nvg\src\NVGLinearGradientElement.cpp \
+	 ..\Internal\Nvg\src\NVGRadialGradientElement.cpp \
+	 ..\Internal\Nvg\src\NVGStopElement.cpp \
+	 ..\Internal\Nvg\src\NVGLineElement.cpp \
+	 ..\Internal\Nvg\src\NVGGElement.cpp \
+	 
+
+SOURCES_C=..\Internal\gfx2d\VGRasterizer\src\svgapi.c \
+	 ..\Internal\gfx2d\VGRasterizer\src\svgmath.c \
+	 ..\Internal\gfx2d\VGRasterizer\src\svgpath.c \
+	 ..\Internal\gfx2d\VGRasterizer\src\svgsubdivide.c 
+
+OBJECTS_CPP_DEB=$(SOURCES_CPP:.cpp=.dbg.o)
+OBJECTS_C_DEB=$(SOURCES_C:.c=.dbg.o)
+OBJECTS_CPP_REL=$(SOURCES_CPP:.cpp=.o)
+OBJECTS_C_REL=$(SOURCES_C:.c=.o)
+
+
+STLPORT_INC=C:\PROGRA~1\MICROS~3\VC98\Include\stlport
+
+INCLUDES=/I"$(PARENT_DIR)" \
+	  /I"$(PARENT_DIR)\inc" \
+	  /I"$(EPOCROOT)epoc32\include" \
+	  /I"$(STLPORT_INC)"
+
+VPATH=$(PARENT_DIR)
+CC=cl.exe
+LINK=link.exe
+LINK32_FLAGS= ..\lib\xerces-c_2.lib
+DEFINES = /nologo /MT /GX /I "..\Internal\SVGEngine\inc" /I "..\Internal\Gfx2D\inc" /I "..\Internal\Gfx2D\VGRasterizer\inc" /I "..\Internal\Xmldomimpl\inc" /I "..\Internal\SVGImpl\inc\SVGDOM" /I "..\Internal\SVGImpl\inc" /I "..\Internal\Path\inc" /I "..\Internal\xmlReader\inc" /I "..\Internal\Sax2Print" /I "..\Internal\Nvg\inc" /D ARM /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+CLFLAGS = /Od /nologo /GF /W4 /Fd -GX
+
+$(PROGRAM) : $(OBJECTS_CPP) $(OBJECTS_C)
+#	echo $(SOURCES_CPP)
+#	echo $(SOURCES_C)
+	@chdir $(PARENT_DIR) && $(LINK) /OUT:"$(PROGRAM)" $(OBJECTS_CPP) $(OBJECTS_C) $(LINK32_FLAGS)
+
+DEB : $(OBJECTS_CPP_DEB) $(OBJECTS_C_DEB)
+	echo "DEB build Called"
+#	echo $(SOURCES_CPP)
+#	echo $(SOURCES_C)
+	@chdir $(PARENT_DIR) && $(LINK) /OUT:"$(PROGRAM).dbg" $(OBJECTS_CPP_DEB) $(OBJECTS_C_DEB) $(LINK32_FLAGS)
+
+
+REL : $(OBJECTS_CPP_REL) $(OBJECTS_C_REL)
+	echo "REL build Called"
+#	echo $(SOURCES_CPP)
+#	echo $(SOURCES_C)
+	@chdir $(PARENT_DIR) && $(LINK) /OUT:"$(PROGRAM).rel" $(OBJECTS_CPP_REL) $(OBJECTS_C_REL) $(LINK32_FLAGS)
+
+%.o : %.cpp 
+	@chdir $(PARENT_DIR) && $(CC) $(DEFINES) $(CLFLAGS) $(INCLUDES) /Fo"$@" /c $<
+
+%.dbg.o : %.cpp 
+	@chdir $(PARENT_DIR) && $(CC) $(DEFINES) $(CLFLAGS) /Zi $(INCLUDES) /Fo"$@" /c $<
+ 
+%.o : %.c 
+	@chdir $(PARENT_DIR) && $(CC) $(DEFINES) $(CLFLAGS) $(INCLUDES) /Fo"$@" /c $<
+
+%.dbg.o : %.c 
+	@chdir $(PARENT_DIR) && $(CC) $(DEFINES) $(CLFLAGS) /Zi $(INCLUDES) /Fo"$@" /c $<
+
+DEB_install: $(PROGRAM).dbg
+#	echo $(PARENT_DIR)
+#	echo $(BUILD_DIR)
+#	echo $(CURDIR)
+	copy /y "$(PARENT_DIR)\$(PROGRAM).dbg" "\epoc32\RELEASE\tools\deb\$(PROGRAM)"
+	copy /y "\sf\mw\uitools\svgtencoder\svgtenc\standalone\lib\$(XERCES_DLL)" "\epoc32\RELEASE\tools\deb\$(XERCES_DLL)"
+REL_install: $(PROGRAM).rel
+#	echo $(PARENT_DIR)
+#	echo $(BUILD_DIR)
+#	echo $(CURDIR)
+	copy /y "$(PARENT_DIR)\$(PROGRAM).rel" "\epoc32\tools\$(PROGRAM)"
+	copy /y "\sf\mw\uitools\svgtencoder\svgtenc\standalone\lib\$(XERCES_DLL)" "\epoc32\tools\$(XERCES_DLL)"
+DEB_CLEAN:
+#	echo $(CURDIR)
+	@chdir $(PARENT_DIR) && erase /f $(OBJECTS_CPP_DEB) 2>>nul
+	@chdir $(PARENT_DIR) && erase /f $(OBJECTS_C_DEB) 2>>nul
+	@chdir $(PARENT_DIR) && erase /f $(PROGRAM).dbg 2>>nul
+	@erase /f "\epoc32\RELEASE\tools\deb\$(PROGRAM)" 2>>nul
+	@erase /f "\epoc32\RELEASE\tools\deb\$(XERCES_DLL)" 2>>nul
+
+REL_clean:
+#	echo $(CURDIR)
+	@chdir $(PARENT_DIR) && erase /f $(OBJECTS_CPP_REL) 2>>nul
+	@chdir $(PARENT_DIR) && erase /f $(OBJECTS_C_REL) 2>>nul
+	@chdir $(PARENT_DIR) && erase /f $(PROGRAM).rel 2>>nul
+	@erase /f "\epoc32\tools\$(PROGRAM)" 2>>nul
+	@erase /f "\epoc32\tools\$(XERCES_DLL)" 2>>nul
+
+_clean: 
Binary file svgtencoder/svgtenc/standalone/lib/SVGTBinEncode.exe has changed
Binary file svgtencoder/svgtenc/standalone/lib/SYMDEFCPPDLL.dll has changed
Binary file svgtencoder/svgtenc/standalone/lib/SYMDEFCPPDLL.lib has changed
Binary file svgtencoder/svgtenc/standalone/lib/xerces-c_2.lib has changed
Binary file svgtencoder/svgtenc/standalone/lib/xerces-c_2D.lib has changed
Binary file svgtencoder/svgtenc/standalone/lib/xerces-c_2_6.dll has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/systemDefinition.xml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "systemDefinition.dtd"[
+
+ 	<!ENTITY layer_real_source_path "\sf\mw\uitools">
+ 	<!ENTITY layer_name "uitools">
+
+ 	<!ENTITY layer_file SYSTEM "systemDefinitionLayer.xml">
+ 	<!ENTITY targetDefinition_file SYSTEM "/epoc32/tools/systemDefinition/targetDefinition.xml">
+ 	<!ENTITY defaultbuild_file SYSTEM "/epoc32/tools/systemDefinition/default_build.xml">
+ 	<!ENTITY defaultclean_file SYSTEM "/epoc32/tools/systemDefinition/default_clean.xml">
+]>
+
+<SystemDefinition name="SystemDefinition" schema="1.4.0">
+  <systemModel>
+&layer_file;
+  </systemModel>
+  <build>
+&targetDefinition_file;
+
+		<configuration name="build" description="build layer" filter="">
+    	<layerRef layerName="&layer_name;"/>
+
+&defaultbuild_file;
+    </configuration>
+
+		<configuration name="clean" description="clean layer" filter="">
+    	<layerRef layerName="&layer_name;"/>
+
+&defaultclean_file;
+    </configuration>
+
+  </build>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/systemDefinitionLayer.xml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,97 @@
+<layer name="uitools">
+  <module name="group_uitools">
+    <component name="group_uitools">
+      <unit unitID="uitools" mrp="" bldFile="&layer_real_source_path;\group" name="uitools" />
+    </component>
+  </module>
+  <module name="AknLayoutCompiler">
+    <component name="AknLayoutCompiler">
+      <unit unitID="uitools_AknLayoutCompiler" mrp="" filter="not_build" bldFile="&layer_real_source_path;\AknLayoutCompiler\group" name="AknLayoutCompiler" />
+    </component>
+  </module>
+  <module name="cdlcompiler">
+    <component name="cdlcompiler">
+      <unit unitID="uitools_cdlcompiler" mrp="" filter="not_build" bldFile="&layer_real_source_path;\cdlcompiler\group" name="cdlcompiler" />
+    </component>
+  </module>
+  <module name="cdlcompilertoolkit">
+    <component name="cdlcompilertoolkit">
+      <unit unitID="uitools_cdlcompilertoolkit" mrp="" filter="not_build" bldFile="&layer_real_source_path;\cdlcompilertoolkit\group" name="cdlcompilertoolkit" />
+    </component>
+  </module>
+  <module name="gfxtools">
+    <component name="gfxtools">
+      <unit unitID="uitools_gfxtools" mrp="" filter="not_build" bldFile="&layer_real_source_path;\gfxtools\group" name="gfxtools" />
+    </component>
+  </module>
+  <module name="Color">
+    <component name="Color">
+      <unit unitID="uitools_gfxtools_Color" mrp="" filter="not_build" bldFile="&layer_real_source_path;\gfxtools\Color\group" name="Color" />
+    </component>
+  </module>
+  <module name="gditools">
+    <component name="gditools">
+      <unit unitID="uitools_gfxtools_gditools" mrp="" filter="not_build" bldFile="&layer_real_source_path;\gfxtools\gditools\group" name="gditools" />
+    </component>
+  </module>
+  <module name="reszip">
+    <component name="reszip">
+      <unit unitID="uitools_reszip" mrp="" filter="not_build" bldFile="&layer_real_source_path;\reszip\group" name="reszip" />
+    </component>
+  </module>
+  <module name="skincompiler">
+    <component name="skincompiler">
+      <unit unitID="uitools_skincompiler" mrp="" filter="not_build" bldFile="&layer_real_source_path;\skincompiler\group" name="skincompiler" />
+    </component>
+  </module>
+  <module name="AknSkinDescCompiler">
+    <component name="AknSkinDescCompiler">
+      <unit unitID="uitools_skincompiler_AknSkinDescCompiler" mrp="" filter="not_build" bldFile="&layer_real_source_path;\skincompiler\AknSkinDescCompiler\group" name="AknSkinDescCompiler" />
+    </component>
+  </module>
+  <module name="toollibraries">
+    <component name="toollibraries">
+      <unit unitID="uitools_toollibraries" mrp="" filter="not_build" bldFile="&layer_real_source_path;\toollibraries\group" name="toollibraries" />
+    </component>
+  </module>
+  <module name="Arabica">
+    <component name="Arabica">
+      <unit unitID="uitools_toollibraries_Arabica" mrp="" filter="not_build" bldFile="&layer_real_source_path;\toollibraries\Arabica\group" name="Arabica" priority="150"/>
+    </component>
+  </module>
+  <module name="XercesC">
+    <component name="XercesC">
+      <unit unitID="uitools_toollibraries_XercesC" mrp="" filter="not_build" bldFile="&layer_real_source_path;\toollibraries\XercesC\group" name="XercesC" priority="150"/>
+    </component>
+  </module>
+  <module name="uitools_dom">
+    <component name="uitools_dom">
+      <unit unitID="uitools_uitools_dom" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_dom\group" name="uitools_dom" />
+    </component>
+  </module>
+  <module name="cdl_api">
+    <component name="cdl_api">
+      <unit unitID="uitools_uitools_dom_cdl_api" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_dom\cdl_api\group" name="cdl_api" />
+    </component>
+  </module>
+  <module name="layout_data_api">
+    <component name="layout_data_api">
+      <unit unitID="uitools_uitools_dom_layout_data_api" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_dom\layout_data_api\group" name="layout_data_api" />
+    </component>
+  </module>
+  <module name="layout_system_private_api">
+    <component name="layout_system_private_api">
+      <unit unitID="uitools_uitools_dom_layout_system_private_api" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_dom\layout_system_private_api\group" name="layout_system_private_api" />
+    </component>
+  </module>
+  <module name="uitools_sdk">
+    <component name="uitools_sdk">
+      <unit unitID="uitools_uitools_sdk" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_sdk\group" name="uitools_sdk" />
+    </component>
+  </module>
+  <module name="third_party_bitmap_palette_api">
+    <component name="third_party_bitmap_palette_api">
+      <unit unitID="uitools_uitools_sdk_third_party_bitmap_palette_api" mrp="" filter="not_build" bldFile="&layer_real_source_path;\uitools_sdk\third_party_bitmap_palette_api\group" name="third_party_bitmap_palette_api" />
+    </component>
+  </module>
+</layer>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toollibraries/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,19 @@
+/*
+* 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 "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:
+*
+*/
+
+#include "../xercesc/group/bld.inf"
+#include "../arabica/group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/cdl_api.metaxml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="5fba3408ef1074b5d8181495e5429c66" dataversion="1.0">
+  <name>CDL API</name>
+  <description>Provides CdlCompilerToolkit functionality.</description>
+  <type>c++</type>
+  <subsystem>uitools</subsystem>
+  <libs>
+  	<lib name="CdlCompilerToolkit.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* 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 "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:  File that exports the files belonging to 
+:                CDL API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/CdlDef.h     MW_LAYER_PLATFORM_EXPORT_PATH(CdlDef.h)
+../inc/CdlCompilerToolkit/CdlTkInstance.h     MW_LAYER_PLATFORM_EXPORT_PATH(CdlCompilerToolkit/CdlTkInstance.h)
+../inc/CdlCompilerToolkit/CdlTkInterface.h     MW_LAYER_PLATFORM_EXPORT_PATH(CdlCompilerToolkit/CdlTkInterface.h)
+../inc/CdlCompilerToolkit/CdlTkUtil.h     MW_LAYER_PLATFORM_EXPORT_PATH(CdlCompilerToolkit/CdlTkUtil.h)
+../inc/CdlCompilerToolkit/CdlTkProcess.h     MW_LAYER_PLATFORM_EXPORT_PATH(CdlCompilerToolkit/CdlTkProcess.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkInstance.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,509 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef CDLTKINSTANCE_H
+#define CDLTKINSTANCE_H
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+
+#include <CdlCompilerToolkit/CdlTkInterface.h>
+#include <vector>
+#include <set>
+
+namespace CdlCompilerToolkit {
+
+class CCdlTkDll;
+class CCdlTkInstance;
+
+const int KCdlTkGetInstanceIdFromHostDll = -1;
+
+/**
+* The implementation of a single API from a CDL interface.
+*/
+class CCdlTkImplementation
+	{
+public:
+	/**
+    * constructor
+    * @param aInstance the customisation instance to which this implementation belongs
+	* @param aApi the API that this implements
+    */
+	CCdlTkImplementation(const CCdlTkInstance& aInstance, const CCdlTkApi& aApi);
+	/**
+    * destructor
+    */
+	~CCdlTkImplementation();
+
+	/**
+    * Get the implementation's definition.
+    * @return the implementation's definition.
+    */
+	std::string Definition() const;
+	/**
+    * Set the implementation's definition.
+    * @param aDefn the implementation's definition.
+    */
+	void SetDefinition(const std::string& aDefn);
+	/**
+    * Set the implementation's definition to be that defined by the data type translations
+	* provided by the interface.
+    */
+	void SetTemplateDefinition();
+	/**
+    * Get a pointer reference for the implementation.
+    * @return a pointer reference for the implementation.
+    */
+	std::string PointerReference() const;
+	/**
+    * Set a pointer reference for the implementation.
+    * @param aPtr a pointer reference for the implementation.
+    */
+	void SetPointerReference(const std::string& aPtr);
+	/**
+    * Set the implementation's pointer reference to be that defined by the data type translations
+	* provided by the interface.
+    */
+	void SetTemplatePointerReference();
+
+	/**
+    * Set both the definition and pointer reference to be that defined by the data type 
+	* translations provided by the interface.
+    */
+	void SetTemplate();
+	/**
+    * Set an empty definition and NULL pointer reference
+    */
+	void SetNull();
+
+	/**
+    * Get the customisation instance to which this implementation belongs
+    * @return the customisation instance to which this implementation belongs
+    */
+	const CCdlTkInstance& Instance() const;
+	/**
+    * Get the API which this implementation implements
+    * @return the API which this implementation implements
+    */
+	const CCdlTkApi& Api() const;
+	/**
+    * Get the name of the implementation, which is also the name of API that this implements
+    * @return the name of the implementation
+    */
+	const std::string& Name() const;
+
+private:
+	const CCdlTkDataTypeTranslation* GetTranslation(const std::string& aType, std::string& aTypeVar);
+
+private:
+	const CCdlTkInstance& iInstance;
+	const CCdlTkApi& iApi;
+	std::string iDefn;
+	std::string iPtr;
+	};
+
+/**
+* A collection of implementations of the APIs in an API list. There is one implementation
+* for each API and they appear in the same order as the API list.
+*/
+class CCdlTkImplementations
+	{
+private:
+	typedef std::vector<CCdlTkImplementation*> CImpl;
+
+public:
+	/**
+    * constructor
+    * @param aInstance the customisation instance to which these implementations belong
+	* @param aApiList the APIs that define what implementations appear in this collection
+    */
+	CCdlTkImplementations(const CCdlTkInstance& aInstance, const CCdlTkApiList& aApiList);
+	/**
+    * destructor
+    */
+	~CCdlTkImplementations();
+
+	/**
+    * Find an implementation by name
+    * @param aName the name of the implemntation to find
+    * @return the implmentation, or NULL if none is found
+    */
+	CCdlTkImplementation* Find(const std::string& aName) const;
+	/**
+    * Set all implementations to be null.
+    */
+	void ClearAll();
+	/**
+    * Set all implementations to have the template definition and pointer reference syntax
+	* defined by the data type translations from the interface.
+    */
+	void TemplateAll();
+
+public:
+	// iterator interface
+	/**
+    * The iterator type
+    */
+	typedef CImpl::iterator iterator;
+	/**
+    * The const iterator type
+    */
+	typedef CImpl::const_iterator const_iterator;
+	/**
+    * begin iterator
+    */
+	iterator begin() { return iImpl.begin(); }
+	/**
+    * begin iterator
+    */
+	const_iterator begin() const { return iImpl.begin(); }
+	/**
+    * end iterator
+    */
+	iterator end() { return iImpl.end(); }
+	/**
+    * end iterator
+    */
+	const_iterator end() const { return iImpl.end(); }
+
+private:
+	CImpl iImpl;
+	};
+
+
+/**
+* a customisation instance
+*/
+class CCdlTkInstance
+	{
+public:
+	/**
+    * constructor
+    * @param aInterface the CDL interface that this instance implements
+    */
+	CCdlTkInstance(const CCdlTkInterface& aInterface);
+	/**
+    * destructor
+    */
+	~CCdlTkInstance();
+
+	/**
+    * Get the implementations that make up this instance
+    * @return the implementations that make up this instance
+    */
+	CCdlTkImplementations& Impl();
+	/**
+    * Get the implementations that make up this instance
+    * @return the implementations that make up this instance
+    */
+	const CCdlTkImplementations& Impl() const;
+	/**
+    * Set all implementations to be null.
+    */
+	void ClearAllImplementations();
+	/**
+    * Set all implementations to have the template definition and pointer reference syntax
+	* defined by the data type translations from the interface.
+    */
+	void TemplateAllImplementations();
+
+	/**
+    * Set the name of this customisation instance
+    * @param aName the name of this customisation instance
+    */
+	void SetName(const std::string& aName);
+	/**
+    * Get the name of this customisation instance
+    * @return the name of this customisation instance
+    */
+	const std::string& Name() const;
+	/**
+    * Get an identifier for this customisation instance that its
+	* host DLL can use to identify it.
+    * @return the fully qualified name of this customisation instance
+    */
+	std::string DllInstanceName() const;
+	/**
+    * Turn an instance name into an identifier that a DLL can use to set
+	* the instance id.
+	* @param aName the instance name
+    * @return the DLL instance id string
+    */
+	static std::string InstanceNameToDllInstanceName(const std::string& aName);
+
+	/**
+    * Set the id of this customisation instance to be got from the host DLL. 
+	* The id is used to distinguish this instance from others in a customisation DLL.
+	* Getting the id from the host DLL optimised the lookup process.
+	* Note, the instance is automatically created with the this id. So, this
+	* function only needs to be used if the id has been previously set to another
+	* value.
+    */
+	void SetId();
+	/**
+    * Set the id of this customisation instance. 
+	* The id is used to distinguish this instance from others in a customisation DLL.
+	* This function does not generate as efficient code as SetId()
+    * @param aId the id of this customisation instance
+    */
+	void SetId(int aId);
+	/**
+    * Get the id of this customisation instance. 
+	* The id is used to distinguish this instance
+	* from others in a customisation DLL.
+    * @return the id of this customisation instance, which may be
+	* KCdlTkGetInstanceIdFromHostDll if the id is to come from the host DLL.
+    */
+	int Id() const;
+
+	/**
+    * Get the interface that this instance implements.
+    * @return the interface that this instance implements.
+    */
+	const CCdlTkInterface& Interface() const;
+
+	/**
+    * Set the extra C++ section for this instance. This may add any extra C++ code required
+	* by the API implementations. For instance, helper functions or #includes
+    * @param aExtra the extra C++ section for this instance
+    */
+	void SetExtraCpp(const std::string& aExtra);
+	/**
+    * Get the extra C++ section for this instance. This may be extra C++ code required
+	* by the API implementations. For instance, helper functions or #includes
+    * @return the extra C++ section for this instance
+    */
+	const std::string& ExtraCpp() const;
+
+private:
+	const CCdlTkInterface& iInterface;
+	CCdlTkImplementations iImpl;
+	std::string iName;
+	int iId;
+	std::string iExtraCpp;
+	};
+
+
+/**
+* A customisation instance that implements a CDL package interface.
+* a CDL package interface is one that contains the following API:
+*   TCdlArray<TCdlRef> contents;
+*/
+class CCdlTkPackage : public CCdlTkInstance
+	{
+private:
+	class CRef
+		{
+	public:
+		CRef();
+		const std::string& LocalInstanceName() const;
+		void SetLocalInstanceName(const std::string& aLocalInstanceName);
+		int Id() const;
+		void SetId(int aId);
+		int Uid() const;
+		void SetUid(int aUid);
+		const std::string& DllName() const;
+		void SetDllName(const std::string& aDllName);
+		const std::string& DllSourcePath() const;
+		void SetDllSourcePath(const std::string& aDllSourcePath);
+		const std::string& DllInstName() const;
+		void SetDllInstName(const std::string& aDllInstName);
+
+	private:
+		std::string iLocalInstanceName;
+		int iId;
+		int iUid;
+		std::string iDllName;
+		std::string iDllSourcePath;
+		std::string iDllInstName;
+		};
+
+	typedef std::vector<CRef> CRefs;
+
+public:
+	/**
+    * constructor
+    * @param aInterface the CDL package interface that this package implements
+    */
+	CCdlTkPackage(const CCdlTkInterface& aInterface);
+	/**
+    * destructor
+    */
+	~CCdlTkPackage();
+	
+	/**
+    * Adds a customisation instance which will appear in the same DLL as this package
+    * @param aInstance a customisation instance to be referenced by this package
+    */
+	void AddLocalContent(const CCdlTkInstance& aInstance);
+	/**
+    * Adds a customisation instance which will appear in the same DLL as this package
+    * @param aLocalInstanceName a customisation instance name to be referenced by this package
+    */
+	void AddLocalContent(const std::string& aLocalInstanceName);
+	/**
+    * Adds a customisation instance which will appear in another DLL to this package
+    * @param aInstance the instance to add to this package
+	* @param aDll the DLL that the instance appears in.
+	* @param aDllSourcePath the path to the source code for the DLL that 
+	* the instance appears in. This may be an empty string if the instance
+	* has an instance id other than KCdlTkGetInstanceIdFromHostDll, or if the
+	* instance appears in the same DLL as this package.
+    */
+	void AddContent(const CCdlTkInstance& aInstance, const CCdlTkDll& aDll, const std::string& aDllSourcePath);
+	/**
+    * Adds a customisation instance which may appear in another DLL to this package
+    * @param aId the id of the customisation instance.
+    * @param aUid the UID of the customisation instance's interface
+    * @param aDllName the DLL in which the customisation instance appears. This may be
+	* an empty string if the instance appears in the same DLL as this package.
+    */
+	void AddContent(int aId, int aUid, const std::string& aDllName);
+	/**
+    * Adds a customisation instance which appears in another DLL created by the
+	* CDL compiler, and whose source is available.
+    * @param aInstanceName the customisation instance name used in the other DLL
+    * @param aDllSourcePath the path to the other DLLs source
+    * @param aDllName the name of the other DLL
+    */
+	void AddExternalContent(const std::string& aInstanceName, const std::string& aDllSourcePath, const std::string& aDllName);
+
+private:
+	const CRefs& Contents() const;
+	void GenerateImpl();
+	void AddIncludesAndBuildDllSet(std::string& aDefn, std::set<std::string>& aDllNames);
+	void AddDllNameLits(std::string& aDefn, std::set<std::string>& aDllNames);
+	void AddContents(std::string& aDefn);
+
+private:
+	CRefs iContents;
+	CCdlTkImplementation* iContentsImpl;	// not owned, can't be initialised until base class is constructed
+	};
+
+
+/**
+* a customisation DLLs contents and build information
+*/
+class CCdlTkDll
+	{
+public:
+	/**
+    * a collection of customisation instance names that will appear in the DLL
+    */
+	typedef std::vector<std::string> CInstances;
+	/**
+    * a collection of libraries that the DLL needs to link to
+    */
+	typedef std::vector<std::string> CLibraries;
+
+public:
+	/**
+    * constructor
+    */
+	CCdlTkDll();
+	/**
+    * destructor
+    */
+	~CCdlTkDll();
+	
+	/**
+    * Adds a customisation instance to the DLL
+    * @param aInstance a customisation instance
+    */
+	void AddInstance(const CCdlTkInstance& aInstance);
+	/**
+    * Adds a customisation instance to the DLL
+    * @param aInstanceName the name of a customisation instance
+    */
+	void AddInstance(const std::string& aInstanceName);
+	/**
+    * Gets the collection of customisation instances that appear in this DLL
+    * @return the collection of customisation instances that appear in this DLL
+    */
+	const CInstances& Instances() const;
+	
+	/**
+    * Set the name of the DLL
+    * @param aName the name of the DLL
+    */
+	void SetName(const std::string& aName);
+	/**
+    * Get the name of the DLL
+    * @return the name of the DLL
+    */
+	const std::string& Name() const;
+
+	/**
+    * Set the UID of the DLL
+    * @param aUid the UID of the DLL
+    */
+	void SetUid(int aUid);
+	/**
+    * Get the UID of the DLL
+    * @return the UID of the DLL
+    */
+	int Uid() const;
+
+	/**
+    * Set the version of the DLL
+    * @param aVersion the version number of the DLL
+    */
+	void SetVersion(int aVersion);
+	/**
+    * Get the version number of the DLL
+    * @return the version number of the DLL
+    */
+	int Version() const;
+
+	/**
+    * Add a library name to the DLL
+    * @param aLibName a library name
+    */
+	void AddLibrary(const std::string& aLibName);
+	/**
+    * Get the collection of libraries that this DLL links to
+    * @return the collection of libraries that this DLL links to
+    */
+	const CLibraries& Libraries() const;
+	/**
+    * Get the collection of libraries that this DLL links to
+    * @return the collection of libraries that this DLL links to
+    */
+	CLibraries& Libraries();
+
+	/**
+    * Set any extra MMP file content that the DLL needs
+    * @param aExtraMmp extra MMP file content that the DLL needs
+    */
+	void SetExtraMmp(const std::string& aExtraMmp);
+	/**
+    * Get the extra MMP file content that has been set for the DLL
+    * @return the extra MMP file content that has been set for the DLL
+    */
+	const std::string& ExtraMmp() const;
+
+private:
+	std::string iName;
+	int iUid;
+	CInstances iInstances;
+	CLibraries iLibraries;
+	std::string iExtraMmp;
+	std::set<std::string> iUniqueInstances;
+	int iVersion;
+	};
+
+
+}	// end of namespace CdlCompilerToolkit
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkInterface.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,976 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef CDLTKINTERFACE_H
+#define CDLTKINTERFACE_H
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+
+
+#include <vector>
+#include <set>
+#include <string>
+#include <CdlCompilerToolkit/CdlTkUtil.h>
+
+namespace CdlCompilerToolkit {
+
+class CCdlTkInterface;
+class CCdlTkFunctionApi;
+class CCdlTkDataApi;
+
+
+/**
+* Header information for a CDL interface
+*/
+class CCdlTkInterfaceHeader
+	{
+public:
+	/**
+	* A collection of CDL interface flags. This class has operations to allow
+	* the flags to be manipulated through their textual name, or as an array
+	* of bits.
+	*/
+	class CFlags
+		{
+	public:
+		/**
+		* constructor
+		*/
+		CFlags();
+		
+		/**
+		* Sets a flag to be on
+		* @param aFlagName the name of the flag to be turned on
+		*/
+		void SetFlag(const std::string& aFlagName);
+		/**
+		* Sets a flag to be off
+		* @param aFlagName the name of the flag to be turned off
+		*/
+		void ClearFlag(const std::string& aFlagName);
+		
+		/**
+		* Returns a representation of the flags as a 32-bit integer
+		* @return a 32-bit integer containing a bit patterns representing the flags
+		*/
+		int FlagsAsInt() const;
+		/**
+		* Returns a string representation of the flags
+		* @return a string containing the set flags' names combined with the
+		* C++ bitwise OR operator |.
+		* If no flags are set, "0" is returned.
+		*/
+		std::string FlagsAsString() const;
+
+		/**
+		* Gives the number of bit flags that this class uses.
+		* @return the  number of bit flags that this class uses.
+		*/
+		int Count() const;
+		/**
+		* Test whether a flag is set, using a flag index between 0 and Count()-1
+		* to identify the flag.
+		* @param aFlagIndex the index of the flag in question
+		* @return the bool value of the flag
+		*/
+		bool IsSet(int aFlagIndex) const;
+		/**
+		* Test whether a flag is set, using the flag name to identify the flag
+		* @param aFlagName the name of the flag in question
+		* @return the bool value of the flag
+		*/
+		bool IsSet(const std::string& aFlagName) const;
+
+		/**
+		* Adds the set flags in another CFlags object to this one.
+		* @param aOther another CFlags object
+		* @return this modified object.
+		*/
+		CFlags& operator|=(const CFlags& aOther);
+
+		/**
+		* Returns the name of a flag identified by its index
+		* @param aFlagIndex the index of the flag, between 0 and Count()-1
+		* @return the name of the flag
+		*/
+		std::string FlagName(int aFlagIndex) const;
+
+	private:
+		int IndexToFlagVal(int aIndex) const;
+		int FlagVal(const std::string& aFlagName) const;
+
+	private:
+		int iFlags;
+		};
+
+	/**
+	* A version number
+	*/
+	class CVersion
+		{
+	public:
+		/**
+		* constructor
+		*/
+		CVersion();
+		/**
+		* constructor
+		* @param aMajor the major version number
+		* @param aMinor the minor version number
+		*/
+		CVersion(int aMajor, int aMinor);
+	
+		/**
+		* Compare two versions
+		* @param aOther another version number
+		* @return true if this version is less than the other version
+		*/
+		bool operator<(const CVersion aOther) const;
+		/**
+		* Compare two versions
+		* @param aOther another version number
+		* @return true if the two versions are equal
+		*/
+		bool operator==(const CVersion aOther) const;
+
+		/**
+		* The major version number
+		* @return the major version number
+		*/
+		int Major() const;
+		/**
+		* Set the major verion number
+		* @param aMajor the major version number
+		*/
+		void SetMajor(int aMajor);
+		/**
+		* The minor version number
+		* @return the minor version number
+		*/
+		int Minor() const;
+		/**
+		* Set the minor verion number
+		* @param aMinor the minor version number
+		*/
+		void SetMinor(int aMinor);
+
+	private:
+		int iMajor;
+		int iMinor;
+		};
+
+public:
+	/**
+    * constructor
+    */
+	CCdlTkInterfaceHeader();
+	/**
+    * Merge another header in with this one. This process is normally used
+	* when colapsing an extended CDL interface into a monolithic one.
+	* The other header is checked to make sure that it does nothing illegal,
+	* like change the name or UID, or decrease the version number, before the
+	* flags are merged and the version number is copied.
+    * @param aOther the header to merge with this one.
+    */
+	void MergeExtensionHeader(const CCdlTkInterfaceHeader& aOther);
+
+	/**
+    * Get the name of the CDL interface
+    * @return the name
+    */
+	std::string Name() const;
+	/**
+    * Set the name of the CDL interface
+    * @param aName the name for the CDL interface
+    */
+	void SetName(const std::string& aName);
+
+	/**
+    * Get the UID of the CDL interface
+    * @return the UID
+    */
+	int Uid() const;
+	/**
+    * Set the UID of the CDL interface
+    * @param aUid the UID for the CDL interface
+    */
+	void SetUid(int aUid);
+
+	/**
+    * Set the version of the CDL interface.
+    * @param aVersion The version for the interface
+    */
+	void SetVersion(const CVersion& aVersion);
+	/**
+    * Get the version of the CDL interface.
+    * @return the version of the CDL interface.
+    */
+	const CVersion& Version() const;
+
+	/**
+    * Get the flags for the CDL interface.
+    * @return the flags
+    */
+	const CFlags& Flags() const;
+	/**
+    * Get the flags for the CDL interface.
+    * @return a modifiable flags object
+    */
+	CFlags& Flags();
+
+	/**
+    * Compare this header with another
+    * @param aOther a header to compare this one with
+    * @return true if they are equal
+    */
+	bool operator==(const CCdlTkInterfaceHeader& aOther) const;
+
+private:
+	std::string iName;
+	int iUid;
+	CVersion iVer;
+	CFlags iFlags;
+	};
+
+
+/**
+* A single parameter in a function API in a CDL interface. It contains
+* a type and a name.
+*/
+class CCdlTkApiParam
+	{
+public:
+	/**
+    * constructor
+    */
+	CCdlTkApiParam();
+	/**
+    * constructor
+    * @param aType the parameter type
+	* @param aName the parameter name
+    */
+	CCdlTkApiParam(const std::string& aType, const std::string& aName);
+	/**
+    * constructor
+    * @param aType the parameter type
+	* @param aName the parameter name
+	* @param aDefaultValue the default value - If the supplied value is empty, there will be no default value
+    */
+	CCdlTkApiParam(const std::string& aType, const std::string& aName, const std::string& aDefaultValue);
+
+	/**
+    * Get the parameter type
+    * @return the parameter type
+    */
+	const std::string& Type() const;
+	/**
+    * Set the parameter type
+    * @param aType the type for the parameter
+    */
+	void SetType(const std::string& aType);
+
+	/**
+    * Get the parameter name
+    * @return the parameter name
+    */
+	const std::string& Name() const;
+	/**
+    * Set the parameter name
+    * @param aName the parameter name
+    */
+	void SetName(const std::string& aName);
+
+	/**
+    * Get the default value
+    * @return the default value - If there is no default value, the return value will be empty
+    */
+	const std::string& DefaultValue() const;
+	/**
+    * Set the default value
+    * @param aDefaultValue the default value  - If the supplied value is empty, there will be no default value
+    */
+	void SetDefaultValue(const std::string& aDefaultValue);
+
+	/**
+    * compare two parameters
+    * @param aOther the parameter to compare with
+    * @return true if name, type, and default value are the same
+    */
+	bool operator==(const CCdlTkApiParam& aOther) const;
+
+	/**
+    * compare two parameters
+    * @param aOther the parameter to compare with
+    * @return true if any of name, type, and default value are not the same
+    */
+	bool operator!=(const CCdlTkApiParam& aOther) const
+		{
+		return !(*this == aOther);
+		}
+
+private:
+	std::string iType;
+	std::string iName;
+	std::string iDefaultValue;
+	};
+
+
+/**
+* The parameter list for a function API in a CDL interface
+*/
+class CCdlTkApiParams : public std::vector<CCdlTkApiParam>
+	{
+public:
+	/**
+    * Finds a parameter by its name
+    * @param aParamName the name of the parameter to look for
+    * @return an iterator pointing at the parameter, or end() if not found.
+    */
+	iterator FindByName(std::string aParamName);
+	};
+
+
+/**
+* A CDL data type translation.
+* Data type translations have three parts.
+* 1) the type that the translation matches.
+* 2) the syntax for defining an instance of that type.
+* 3) the pointer reference syntax for that type.
+* The type match string may contain the text "aType". This will match against
+* any content in a type to be matched.
+* The definition and pointer reference strings may contain the variables
+* "aName" and "aType". "aName" will be replaced by the instance name.
+* "aType" will be replaced by the text in the type string that matched "aType".
+*/
+class CCdlTkDataTypeTranslation
+	{
+public:
+	/**
+    * An enum used to identify the source of a data type translation, whether
+	* it is built into the CDL compiler toolkit, or it comes from a CDL file.
+    */
+	enum TTranslationSource
+		{
+		EInbuilt,
+		EFromCdl
+		};
+
+public:
+	/**
+    * constructor
+    */
+	CCdlTkDataTypeTranslation();
+	/**
+    * constructor
+    * @param aType the type that this translation matches
+    */
+	CCdlTkDataTypeTranslation(const std::string& aType);
+	/**
+    * constructor
+    * @param aType the type that this translation matches
+	* @param aDefn the definition syntax for instances of this type.
+	* @param aPtrRef the pointer reference syntax for instances of this type.
+	* @param aSource the source of this translation.
+    */
+	CCdlTkDataTypeTranslation(const std::string& aType, const std::string& aDefn, const std::string& aPtrRef, TTranslationSource aSource);
+
+	/**
+    * Get the type match string
+    * @return the type match string
+    */
+	std::string Type() const;
+	/**
+    * Set the type match string
+    * @param aType the type match string
+    */
+	void SetType(const std::string& aType);
+	/**
+    * Get the definition syntax string
+    * @return the definition syntax string
+    */
+	std::string Definition() const;
+	/**
+    * Set the definition syntax string
+    * @param aDefn the definition syntax string
+    */
+	void SetDefinition(const std::string& aDefn);
+	/**
+    * Get the pointer reference syntax
+    * @return the pointer reference syntax
+    */
+	std::string PointerReference() const;
+	/**
+    * Set the pointer reference syntax
+    * @param aPtrRef the pointer reference syntax
+    */
+	void SetPointerReference(const std::string& aPtrRef);
+	/**
+    * Get the source of the translation
+    * @return the source of the translation
+    */
+	TTranslationSource Source() const;
+
+	/**
+    * Attempts to match a type string against the type string in this translation.
+	* Where this translation doesn't use "aType" in its type string, this is
+	* a simple comparison between they type strings.
+	* Where this translation does use "aType" in its type string, that will match
+	* any text in aType, but the rest of the type strings must match exactly.
+	* The part of aType that matches the string "aType" will be returned in
+	* aTypeVar.
+	* For example, consider when this translation's type is "vector<aType>".
+	* It will match a type "vector<int>" and "int" will be placed into aTypeVar.
+	* However it will not match "list<int>", because "list<>" does not match "vector<>".
+    * @param aType the type string to match.
+	* @param aTypeVar the text in aType that matched the type variable "aType".
+    * @return true if the match succeded.
+    */
+	bool Match(const std::string& aType, std::string& aTypeVar) const;
+
+	/**
+    * Compare two type translations.
+    * @param aOther a translation to compare
+    * @return true if type, definition syntax, pointer reference syntax and
+	* source are all the same.
+    */
+	bool operator==(const CCdlTkDataTypeTranslation& aOther) const;
+
+private:
+	std::string iType;
+	std::string iDefn;
+	std::string iPtrRef;
+	TTranslationSource iSource;
+	// member data used in Match() calculation
+	std::string iTextBeforeTypeVar;
+	std::string iTextAfterTypeVar;
+	int iTypeVarPos;
+	int iSizeAfterTypeVar;
+	int iTypeSize;
+	int iTypeSizeWithoutTypeVar;
+	};
+
+
+/**
+* A collection of data type translations
+*/
+class CCdlTkDataTypeTranslations : public std::vector<CCdlTkDataTypeTranslation>
+	{
+public:
+	/**
+    * constructor
+	* Adds all the inbuilt translations.
+    */
+	CCdlTkDataTypeTranslations();
+	/**
+    * Merges adds another collection of translations to the end of this one.
+	* Inbuilt translations are ignored, as they will already be in this collection.
+    * @param aOther another collection of translations.
+    */
+	void MergeExtensionTranslations(const CCdlTkDataTypeTranslations& aOther);
+	/**
+    * Finds the last translation in the collection that matches the type.
+	* Note, translations are searched from last to first, so that more recently
+	* added translations can overrideolder ones.
+    * @param aType the type string to match.
+	* @param aTypeVar the text in aType that matched the type variable "aType".
+    * @return a pointer to the translation for which the match succeded, or 
+	* NULL if no match succeded.
+    */
+	const CCdlTkDataTypeTranslation* Find(const std::string& aType, std::string& aTypeVar) const;
+	};
+
+
+/**
+* The base class for an individual API in a CDL interface
+*/
+class CCdlTkApi
+	{
+public:
+	/**
+    * constructor
+    * @param aInterface the interface that this API belongs to
+    */
+	CCdlTkApi(CCdlTkInterface& aInterface);
+	/**
+    * destructor
+    */
+	virtual ~CCdlTkApi();
+
+	/**
+    * Create a new copy of this API
+    * @param aInterface the interface to which the new copy will belong
+    * @return a new copy of this API
+    */
+	virtual CCdlTkApi* Clone(CCdlTkInterface& aInterface) const = 0;
+
+	/**
+    * Get the return type for this API
+    * @return the return type
+    */
+	const std::string& ReturnType() const;
+	/**
+    * Set the return type for this API
+    * @param aType the return type
+    */
+	void SetReturnType(const std::string& aType);
+	/**
+    * Does this API return void?
+    * @return true if this API returns void.
+    */
+	bool IsVoidReturn() const;
+
+	/**
+    * Get the name of the API
+    * @return the name of the API
+    */
+	const std::string& Name() const;
+	/**
+    * Set the name of the API
+    * @param aName the name of the API
+    */
+	void SetName(const std::string& aName);
+
+	/**
+    * Get the line number of the source file where the API appeared
+    * @return the line number of the source file where the API appeared
+    */
+	int SourceFileLineNum() const;
+	/**
+    * Set the line number of the source file where the API appeared
+    * @param aLineNum the line number of the source file where the API appeared
+    */
+	void SetSourceFileLineNum(int aLineNum);
+
+	/**
+    * Get the comment text for the API
+    * @return the comment text for the API
+    */
+	const std::string& Comment() const;
+	/**
+    * Set the comment text for the API
+    * @param aComment the comment text for the API
+    */
+	void SetComment(const std::string& aComment);
+
+	/**
+    * Get the interface to which this API belongs
+    * @return the interface to which this API belongs
+    */
+	const CCdlTkInterface& Interface() const;
+	/**
+    * Get the interface to which this API belongs
+    * @return the interface to which this API belongs
+    */
+	CCdlTkInterface& Interface();
+
+	/**
+    * Return whether this API is a function API
+    * @return true if it is a function API, false if it is a data API
+    */
+	virtual bool IsFunc() const = 0;
+	/**
+    * Downcast this object to a function API
+    * @return this object as a function API
+    */
+	const CCdlTkFunctionApi& AsFunc() const;
+	/**
+    * Downcast this object to a data API
+    * @return this object as a data API
+    */
+	const CCdlTkDataApi& AsData() const;
+
+	/**
+    * Get the type of a pointer to this API
+    * @return the type of a pointer to this API
+    */
+	virtual std::string PointerType() const = 0;
+	/**
+    * Get the type and name list for the paramters to this API, will be
+	* empty for data APIs.
+    * @return the type and name list for the paramters to this API
+    */
+	virtual std::string ParamsTypeAndNameList() const = 0;
+
+	/**
+    * Test for inequality
+    * @param aOther an API to compare
+    * @return true if not equal
+    */
+	bool operator!=(const CCdlTkApi& aOther) const;
+	/**
+    * Test for equality
+    * @param aOther an API to compare
+    * @return true if equal
+    */
+	virtual bool operator==(const CCdlTkApi& aOther) const;
+	/**
+    * Assign the contents of another API to this one
+    * @param a 
+    * @return 
+    */
+	void operator=(const CCdlTkApi& aOther);
+
+private:
+	std::string iReturnType;
+	std::string iName;
+	int iSourceFileLineNum;
+	CCdlTkInterface& iInterface;
+	std::string iComment;
+	};
+
+
+/**
+* An individual data API belonging to a CDL interface
+*/
+class CCdlTkDataApi : public CCdlTkApi
+	{
+public:
+	/**
+    * constructor
+    * @param aInterface the interface to which this API belongs
+    */
+	CCdlTkDataApi(CCdlTkInterface& aInterface);
+	/**
+    * constructor
+    * @param aInterface the interface to which this API belongs
+	* @param aCopy an API to copy
+    */
+	CCdlTkDataApi(CCdlTkInterface& aInterface, const CCdlTkDataApi& aCopy);
+
+	// from CCdlTkApi
+	CCdlTkApi* Clone(CCdlTkInterface& aInterface) const;
+	bool IsFunc() const;
+	std::string PointerType() const;
+	std::string ParamsTypeAndNameList() const;
+	};
+
+
+/**
+* An individual function API belonging to a CDL interface
+*/
+class CCdlTkFunctionApi : public CCdlTkApi
+	{
+public:
+	/**
+    * constructor
+    * @param aInterface the interface to which this API belongs
+    */
+	CCdlTkFunctionApi(CCdlTkInterface& aInterface);
+	/**
+    * constructor
+    * @param aInterface the interface to which this API belongs
+	* @param aCopy an API to copy
+    */
+	CCdlTkFunctionApi(CCdlTkInterface& aInterface, const CCdlTkFunctionApi& aCopy);
+
+	/**
+    * Get the parameters list for this function
+    * @return  the parameters list for this function
+    */
+	CCdlTkApiParams& Params();
+	/**
+    * Get the parameters list for this function
+    * @return  the parameters list for this function
+    */
+	const CCdlTkApiParams& Params() const;
+	/**
+    * Get the list of parameter names as a comma separated string
+    * @return the list of parameter names as a comma separated string
+    */
+	std::string ParamNameList() const;
+	/**
+    * Get the list of parameter types as a comma separated string
+    * @return the list of parameter types as a comma separated string
+    */
+	std::string ParamTypeList() const;
+	/**
+    * Get a type name for this API.
+    * @return a type name for this API.
+    */
+	std::string ApiNameAsTypeName() const;
+
+	// from CCdlTkApi
+	CCdlTkApi* Clone(CCdlTkInterface& aInterface) const;
+	bool IsFunc() const;
+	std::string PointerType() const;
+	std::string ParamsTypeAndNameList() const;
+
+	bool operator==(const CCdlTkApi& aOther) const;
+
+private:
+	CCdlTkApiParams iParams;
+	};
+
+
+/**
+* A set of APIs belonging to a CDL interface
+*/
+class CCdlTkApiList : public std::vector<CCdlTkApi*>
+	{
+public:
+	/**
+    * constructor
+    */
+	CCdlTkApiList();
+	/**
+    * destructor
+    */
+	~CCdlTkApiList();
+	/**
+    * Appends API from a CDL interface extension to this API to form a monolithic API
+    * @param aOther The API to add
+    */
+	void MergeExtendedApi(CCdlTkInterface& aInterface, const CCdlTkApiList& aOther);
+	/**
+    * Copies APIs from another API list to this one. Existing APIs are removed first.
+	* @param aOther The API list to copy
+    * @param aInterface The CDL interface to which the new APIs will belong
+    */
+	void Copy(const CCdlTkApiList& aOther, CCdlTkInterface& aInterface);
+
+	/**
+    * Finds an API by name
+    * @param aName the name of the API to find
+    * @return a pointer to the API with that name, or NULL if not found
+    */
+	CCdlTkApi* Find(const std::string& aName) const;
+	/**
+    * Compare two API lists
+    * @param aOther the API list to compare
+    * @return true if the API lists are the same, ie the same content in the same order
+    */
+	bool operator==(const CCdlTkApiList& aOther) const;
+	/**
+    * Is this API list a subset of another
+    * @param aOther the candiate superset
+    * @return true if this API list does not contain any APIs that do not appear in the other APL list
+    */
+	bool IsSubsetOf(const CCdlTkApiList& aOther) const;
+
+private:
+	CCdlTkApiList(const CCdlTkApiList& aCopy);
+	void operator=(const CCdlTkApiList& aCopy);
+	void DeleteApis();
+	};
+
+
+/**
+* The C++ section of a CDL file
+*/
+class CCdlTkCpp : public std::vector<std::string>
+	{
+public:
+	/**
+    * constructor
+    */
+	CCdlTkCpp();
+	/**
+    * Adds the contents of another C++ section to the end of this one.
+	* @param aOther the other C++ section
+    */
+	void MergeExtensionCpp(const CCdlTkCpp& aOther);
+	};
+
+
+/**
+* a CDL interface
+*/
+class CCdlTkInterface
+	{
+public:
+	/**
+    * constructor
+    */
+	CCdlTkInterface();
+	/**
+    * copy constructor
+    * @param aCopy the CDL interface to copy
+    */
+	CCdlTkInterface(const CCdlTkInterface& aCopy);
+	/**
+    * assignment operator
+    * @param aCopy the CDL interface to copy
+    */
+	void operator=(const CCdlTkInterface& aCopy);
+	/**
+    * destructor
+    */
+	~CCdlTkInterface();
+
+	/**
+    * Colapse any extended interface into this one to form a monolithic interface
+    */
+	void MergeExtensions();
+
+	/**
+    * Get the CDL interface which this interface extends
+    * @return the CDL interface which this interface extends, or null if this is the base
+    */
+	CCdlTkInterface* Base() const;
+	/**
+    * Set the CDL interface which this interface extends
+    * @param aBase the CDL interface which this interface extends
+    */
+	void SetBase(CCdlTkInterface* aBase);				// does not take ownership
+	/**
+    * Get the ultimate base CDL interface which this interface extends. That is, the base
+	* interface which itself has no base.
+    * @return the ultimate base CDL interface which this interface extends, which may be this object itself
+    */
+	CCdlTkInterface* UltimateBase();
+	/**
+    * Get the ultimate base CDL interface which this interface extends. That is, the base
+	* interface which itself has no base.
+    * @return the ultimate base CDL interface which this interface extends, which may be this object itself
+    */
+	const CCdlTkInterface* UltimateBase() const;
+
+	/**
+    * Gets the immediate extension for this interface.
+    * @return the immediate extension for this interface, or null if it's not extended.
+    */
+	CCdlTkInterface* Extension() const;
+	/**
+    * Sets the immediate extension for this interface. This function takes ownership of the extension.
+    * @param aExtension the CDL interface to be the extension for this interface.
+    */
+	void SetExtension(CCdlTkInterface* aExtension);		// takes ownership
+	/**
+    * Get the tip extension for this interface. Extensions to an interface form a linked
+	* list. This function traverses to the end of the extension list and returns it.
+    * @return the latest extension for this interface, which may be this interface itself if it's not extended
+    */
+	CCdlTkInterface* UltimateExtension();
+	/**
+    * Get the tip extension for this interface. Extensions to an interface form a linked
+	* list. This function traverses to the end of the extension list and returns it.
+    * @return the latest extension for this interface, which may be this interface itself if it's not extended
+    */
+	const CCdlTkInterface* UltimateExtension() const;
+
+	/**
+    * Get the filename for the CDL file for this CDL interface.
+    * @return the filename for this interface's CDL file.
+    */
+	std::string FileName() const;
+	/**
+    * Set the filename for the CDL file for this CDL interface
+    * @param aFileName The file name for this interface's CDL file
+    */
+	void SetFileName(const std::string& aFileName);
+
+	/**
+    * Get the additional comment for this CDL interface
+    * @return the additional comment for this interface's CDL file.
+    */
+	std::string AdditionalComment() const;
+	/**
+    * Set the additional comment for this CDL interface
+	* The caller must provide sufficient annotation for the text to be treated as a 
+	* comment by the compiler, ensuring that the comment is terminated correctly
+    * @param aAdditionalComment The additional commentfor this interface's CDL file
+    */
+	void SetAdditionalComment(const std::string& aAdditionalComment);
+
+	/**
+    * Get the header for this interface
+    * @return the header for this interface
+    */
+	CCdlTkInterfaceHeader& Header();
+	/**
+    * Get the header for this interface
+    * @return the header for this interface
+    */
+	const CCdlTkInterfaceHeader& Header() const;
+	/**
+    * Get the C++ section for this CDL interface
+    * @return the C++ section for this CDL interface
+    */
+	CCdlTkCpp& Cpp();
+	/**
+    * Get the C++ section for this CDL interface
+    * @return the C++ section for this CDL interface
+    */
+	const CCdlTkCpp& Cpp() const;
+	/**
+    * Get the API list for this CDL interface
+    * @return the API list for this CDL interface
+    */
+	CCdlTkApiList& ApiList();
+	/**
+    * Get the API list for this CDL interface
+    * @return the API list for this CDL interface
+    */
+	const CCdlTkApiList& ApiList() const;
+	/**
+    * Get the data type translations for this CDL interface
+    * @return the data type translations for this CDL interface
+    */
+	CCdlTkDataTypeTranslations& DataTypeTranslations();
+	/**
+    * Get the data type translations for this CDL interface
+    * @return the data type translations for this CDL interface
+    */
+	const CCdlTkDataTypeTranslations& DataTypeTranslations() const;
+
+	/**
+    * Get the C++ namespace name for this CDL interface. This is generated from the CDL interface name.
+    * @return the C++ namespace name for this CDL interface.
+    */
+	std::string NamespaceName() const;
+
+	/**
+    * Compare this interface with another
+    * @param aOther The interface to compare
+    * @return true if the interfaces are equal
+    */
+	bool operator==(const CCdlTkInterface& aOther) const;
+
+private:
+	std::string iFileName;
+	std::string iAdditionalComment;
+	CCdlTkInterfaceHeader iHeader;
+	CCdlTkCpp iCpp;
+	CCdlTkApiList iApiList;
+	CCdlTkDataTypeTranslations iDataTypeTranslations;
+	CCdlTkInterface* iBase;			// not owned
+	CCdlTkInterface* iExtension;	// owned
+	};
+
+
+/**
+* A collection of CDL interfaces
+*/
+class CCdlTkInterfaceList : public std::vector<CCdlTkInterface*>
+	{
+public:
+	/**
+    * constructor
+    */
+	CCdlTkInterfaceList();
+	/**
+    * destructor - deletes the interfaces
+    */
+	~CCdlTkInterfaceList();
+
+private:
+	CCdlTkInterfaceList(const CCdlTkInterfaceList& aCopy);
+	void operator=(const CCdlTkInterfaceList& aCopy);
+	};
+
+
+}	// end of namespace CdlCompilerToolkit
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkProcess.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,429 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef CDLTKPROCESS_H
+#define CDLTKPROCESS_H
+
+#include <CdlCompilerToolkit/CdlTkInterface.h>
+#include <CdlCompilerToolkit/CdlTkInstance.h>
+#include <fstream>
+
+namespace CdlCompilerToolkit {
+
+/**
+* CCdlTkProcess
+* Does very little yet.
+*/
+class CCdlTkProcess
+	{
+public:
+	/**
+    * destructor
+    */
+	virtual ~CCdlTkProcess();
+	/**
+    * virtual method to invoke processing
+    */
+	virtual void Process() = 0;
+
+public:
+	static std::string CdlBaseNameAndPath(const CCdlTkInterface& aCdl);
+	static void AssertInterfaceNotExtended(const CCdlTkInterface& aCdl);
+	};
+
+
+/**
+* Base class for processes that write source files
+*/
+class CCdlTkSourceFileWriter : public CCdlTkProcess
+	{
+public:
+	/**
+    * destructor
+    */
+	~CCdlTkSourceFileWriter();
+
+protected:
+	/**
+    * Writes an opening namespace declaration for a CDL interface to a stream
+    * @param aCdl the CDL interface defining the namespace
+	* @param aStream the stream to write to
+    */
+	void WriteNamespaceStart(const CCdlTkInterface& aCdl, std::ofstream& aStream) const;
+	/**
+    * Writes a closing namespace declaration for a CDL interface to a stream
+    * @param aCdl the CDL interface defining the namespace
+	* @param aStream the stream to write to
+    */
+	void WriteNamespaceEnd(const CCdlTkInterface& aCdl, std::ofstream& aStream) const;
+	/**
+    * Calculates a header guard identifier for a file
+    * @param aFileName the file to be protected by the header guard
+    * @return the header guard identifer
+    */
+	std::string HeaderGuardName(const std::string& aFileName) const;
+	/**
+    * Writes the starting declarations for a header file guard
+    * @param aName the file to be protected by the header guard
+	* @param aStream the stream to write to
+    * @return 
+    */
+	void WriteHeaderGuardStart(const std::string& aName, std::ofstream& aStream) const;
+	/**
+    * Writes the ending declaration for a header file guard
+    * @param aName the file to be protected by the header guard
+	* @param aStream the stream to write to
+    * @return 
+    */
+	void WriteHeaderGuardEnd(const std::string& aName, std::ofstream& aStream) const;
+	};
+
+
+/**
+* Process for writing a common definitions header file (.cdl.common.h)
+*/
+class CCdlTkWriteCommonDefs : public CCdlTkSourceFileWriter
+	{
+public:
+	static void ExportCommonDefs(const CCdlTkInterface& aCdl, const std::string& aFileName);
+
+private:
+	/**
+    * constructor
+    * @param aCdl the interface to write. 
+	* @param aStream the stream to write to
+    */
+	CCdlTkWriteCommonDefs(const CCdlTkInterface& aCdl, std::ofstream& aStream, const std::string& aFileName);
+	/**
+    * Creates and writes a common definitions header file (.cdl.common.h)
+    */
+	void Process();
+	void ProcessHRH(std::ofstream& aStream);
+
+private:
+	void WriteApiEnum();
+	void WriteApiTypedefs();
+	std::string TypedefForApi(const CCdlTkApi& aApi) const;
+	std::ofstream& Stream();
+
+private:
+	const CCdlTkInterface& iCdl;
+	std::ofstream* iStream;
+	const std::string& iFileName;
+	};
+
+
+/**
+* Process for writing a C++ client header file for a C++ interface
+*/
+class CCdlTkWriteClientHeader : public CCdlTkSourceFileWriter
+	{
+public:
+	/**
+    * constructor
+    * @param aCdl The interface to write
+    */
+	CCdlTkWriteClientHeader(const CCdlTkInterface& aCdl);
+	/**
+    * destructor
+    */
+	~CCdlTkWriteClientHeader();
+	/**
+    * Creates and writes the header files required by a C++ client to use
+	* a CDL interface.
+    */
+	void Process();
+
+protected:
+	std::string ClientReturnType(const CCdlTkApi& aApi) const;
+
+private:
+	void ProcessApi(std::ofstream& aStream, const std::string& aFileName) const;
+	void WriteApi(const CCdlTkApi& aApi, std::ofstream& aStream, bool aCInstanceMember, const std::string& aIndent) const;
+
+protected:
+	const CCdlTkInterface& iCdl;
+	};
+
+
+/**
+* Process for syntax checking a CDL interface
+*/
+class CCdlTkSyntaxCheck : public CCdlTkWriteClientHeader
+	{
+	/**
+    * constructor
+    * @param aCdl the interface to check
+    */
+	CCdlTkSyntaxCheck(const CCdlTkInterface& aCdl);
+	/**
+    * destructor
+    */
+	~CCdlTkSyntaxCheck();
+	/**
+    * Sets parameters to pass to the C++ compiler which will do the syntax check
+    * @param aParams the parameters for the compiler
+    */
+	void SetParams(std::string aParams);
+	/**
+    * Runs the syntax checking process
+    */
+	void Process();
+
+private: // syntax checking
+	void WriteSyntaxCheckCpp(std::string aName) const;
+	void DoSyntaxCheckBuild(std::string aName) const;
+	void WriteSyntaxCheckApi(const CCdlTkApi& aApi, std::ofstream& aStream) const;
+
+private:
+	std::string iParams;
+	};
+
+
+/**
+* A process for writing a customisation instance to C++ source files
+*/
+class CCdlTkWriteInstance : public CCdlTkSourceFileWriter
+	{
+public:
+	/**
+    * constructor
+    * @param aInstance The instance to write
+    */
+	CCdlTkWriteInstance(const CCdlTkInstance& aInstance);
+	/**
+    * destructor
+    */
+	~CCdlTkWriteInstance();
+	/**
+    * Run the process of creating and writing the C++ source files for a
+	* customisation instance.
+    */
+	void Process();
+
+private:
+	void ProcessCdl() const;
+	void ProcessInstanceApi(std::ofstream& aStream, const std::string& aFileName) const;
+	void ProcessInstance(std::ofstream& aStream, const std::string& aHeaderName) const;
+	void ProcessInstanceHeader(std::ofstream& aStream, const std::string& aFileName) const;
+	void ProcessInstanceHrh(std::ofstream& aStream, const std::string& aFileName) const;
+	void InitReplace(const std::string& aHeaderName);
+
+private:
+	const CCdlTkInstance& iInstance;
+	const CCdlTkInterface& iCdl;
+	CdlTkUtil::CReplaceSet iReplace;
+	};
+
+
+/**
+* A process to write the source and build files for a DLL
+*/
+class CCdlTkWriteDll : public CCdlTkSourceFileWriter
+	{
+public:
+	/**
+    * constructor
+    * @param aDll the DLL to create source and build files for
+    */
+	CCdlTkWriteDll(const CCdlTkDll& aDll);
+	/**
+    * destructor
+    */
+	~CCdlTkWriteDll();
+	/**
+    * Runs the process of creating and writing source and build files for a DLL
+    */
+	void Process();
+
+private:
+	void WriteBldInf() const;
+	void WriteMmp() const;
+	void WriteMainCpp() const;
+	void WriteInstanceIdHeader() const;
+	void WriteEcomRss() const;
+	void WriteEcomDetailRss() const;
+
+private:
+	const CCdlTkDll& iDll;
+	};
+
+
+/**
+* Process for writing a CDL file
+*/
+class CCdlTkWriteCdlFile : public CCdlTkProcess
+	{
+public:
+	/**
+    * constructor
+    * @param aCdl the CDL interface to write
+    */
+	CCdlTkWriteCdlFile(const CCdlTkInterface& aCdl);
+	/**
+    * destructor
+    */
+	~CCdlTkWriteCdlFile();
+	/**
+    * Run the process of writing the CDL interface to a CDL file
+    */
+	void Process();
+
+private:
+	void WriteHeaderComment();
+	void WriteHeader();
+	void WriteSeparator(const std::string& aSection);
+	void WriteCpp();
+	void WriteTranslation();
+	void WriteApi();
+
+private:
+	const CCdlTkInterface* iCdl;
+	std::ofstream iOut;
+	};
+
+
+/**
+* A process for reading a CDL file
+*/
+class CCdlTkCdlFileParser : public CCdlTkProcess
+	{
+public:
+	/**
+    * constructor
+    * @param aFileName the name of the CDL file to be read
+    * @return 
+    */
+	CCdlTkCdlFileParser(const std::string& aFileName);
+	/**
+    * destructor
+    */
+	~CCdlTkCdlFileParser();
+	/**
+    * Loads and parses a CDL file
+    * @param aMergeExtensions tells the parser whether to merge and interface
+	* extensions to form a monolithic API
+    * @return an auto pointer to the CDL interface read from the CDL file
+    */
+	std::auto_ptr<CCdlTkInterface> LoadAndParse(bool aMergeExtensions);
+	/**
+    * virtual Process method from CCdlTkProcess
+	* this function is not to be used
+    */
+	void Process();
+
+private:
+	enum TParseState {EHeader, ECpp, ETranslation, EApi, EEnd, EParseStateCount};
+
+private:
+	void OpenStream();
+	void ParseStream(CCdlTkInterface& aCdl);
+	void CloseStream();
+
+	void ParseHeader(CCdlTkInterface& aCdl, const std::string& aLine);
+	void ParseCpp(CCdlTkInterface& aCdl, const std::string& aLine);
+	void ParseTranslationLine(CCdlTkInterface& aCdl, const std::string& aLine);
+	void ParseApi(CCdlTkInterface& aCdl, const std::string& aLine);
+	std::auto_ptr<CCdlTkApi> CreateApi(CCdlTkInterface& aCdl, std::string& aLine);
+	void ParseApiParams(CCdlTkApiParams& aParams, std::string& aList);
+	void ParseNameTypeAndDefaultValue(std::string& aStr, std::string& aName, std::string& aType, std::string& aDefaultValue);
+	void ParseTranslationText(CCdlTkDataTypeTranslation& aTrans, std::string& aLine);
+
+	std::string GetLine();
+	bool IsSectionBoundary(const std::string& aLine, TParseState& aState);
+	bool MatchLineStart(const std::string& aLine, const std::string& aHeader, std::string& aVal);
+	void StripComments(std::string& aStr, std::string& aComment);
+
+	void SyntaxError(const std::string& aErr);
+
+private:
+	std::string iFileName;
+	std::ifstream iIn;
+	TParseState iState;
+	int iCurrentSourceLineNum;
+	std::string iApiBuf;			// buffer for collecting API declarations
+	std::string iComment;			// buffer for collecting comments
+	};
+
+
+/**
+* Observer mixin interface for the interface checking process
+*/
+class MCdlTkApiCheckObserver
+	{
+public:
+	/**
+    * Called when an interface check is started
+    */
+	virtual void StartCheck() = 0;
+	/**
+    * Called when an interface check is complete
+    */
+	virtual void CheckComplete() = 0;
+	/**
+    * Called when an API is found that appears in both interfaces
+    */
+	virtual void ApiInBoth(const CCdlTkApi& aApi) = 0;
+	/**
+    * Called when an API is found that is only in the right hand interface
+    */
+	virtual void ApiNotInLeft(const CCdlTkApi& aApi) = 0;
+	/**
+    * Called when an API is found that is only in the left hand interface
+    */
+	virtual void ApiNotInRight(const CCdlTkApi& aApi) = 0;
+	};
+
+/**
+* process for checking (diffing) two CDL interfaces' APIs
+*/
+class CCdlTkApiChecker : public CCdlTkProcess
+	{
+public:
+	/**
+    * constructor
+    * @param aLeft a CDL interface to check
+    * @param aRight another CDL interface to check
+    * @param aObserver the observer of the results of the check
+    */
+	CCdlTkApiChecker(const CCdlTkInterface& aLeft, 
+					 const CCdlTkInterface& aRight, 
+					 MCdlTkApiCheckObserver& aObserver);
+	/**
+    * destructor
+    */
+	~CCdlTkApiChecker();
+	/**
+    * Run the process of checking the interfaces' APIs
+    */
+	void Process();
+
+private:
+	typedef CCdlTkApiList::const_iterator CApiListIter;
+	void FailLeft(CApiListIter& aFrom, const CApiListIter& aTo) const;
+	void FailRight(CApiListIter& aFrom, const CApiListIter& aTo) const;
+	void ReSync(CApiListIter& posLeft, CApiListIter& posRight, 
+				const CApiListIter& leftEnd, const CApiListIter& rightEnd) const;
+
+private:
+	const CCdlTkInterface& iLeft;
+	const CCdlTkInterface& iRight;
+	MCdlTkApiCheckObserver& iObserver;
+	};
+
+}	// end of namespace CdlCompilerToolkit
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/inc/CdlCompilerToolkit/CdlTkUtil.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,402 @@
+/*
+* 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 "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:
+*
+*/
+#ifndef CDLTKUTIL_H
+#define CDLTKUTIL_H
+#pragma warning (disable:4786)	// disable "identifier was truncated to '255' characters in the browser information" warning
+
+#include <string>
+#include <iosfwd>
+#include <vector>
+#include <CdlDef.h>
+
+namespace CdlCompilerToolkit {
+
+class CCdlTkFileCleanup;
+
+/**
+* This is a collection of utility functions that the CDL compiler toolkit uses
+* and which may be of use to other tools based on this toolkit
+*/
+class CdlTkUtil
+	{
+private:
+	typedef std::pair<std::string, std::string> CReplaceTerm;
+
+public:
+	/**
+    * Gives the current working drive
+    * @return the drive as a "X:" string.
+    */
+	static std::string CurrentDrive();
+	/**
+    * Gives the current working directory, without drive
+    * @return the current working directory
+    */
+	static std::string CurrentDir();
+	/**
+    * Gives the current output path for generated files
+    * @return the output path
+    */
+	static std::string OutputPath();
+	/**
+    * Sets the curreent output path for generated files
+    * @param aPath the output path for generated files
+    */
+	static void SetOutputPath(const std::string& aPath);
+
+	/**
+    * Gives the command line used to run the tool using this toolkit
+    * @return the command line, will be empty if SetCommandLine() is not called
+    */
+	static std::string CommandLine();
+	/**
+    * Sets the command line for the tool using this toolkit.
+    */
+	static void SetCommandLine(int argc, char* argv[]);
+
+	/**
+    * Extract an int from the string. This function automatically detects
+	* bases 8, 10 and 16.
+    * @param aInt a string containing an integer
+    * @return the integer value parsed
+    */
+	static int ParseInt(const std::string& aInt);
+	/**
+    * Formats an integer as a string
+    * @param aInt the integer to format
+    * @return a string representing the integer in base 10
+    */
+	static std::string IntToString(int aInt);
+	/**
+    * Formats an integer as a hex string
+    * @param aInt the integer to format
+    * @return a string representing the integer in base 16
+    */
+	static std::string IntToHexString(int aInt);
+	/**
+    * Formats a short integer as a hex string
+    * @param aInt the integer to format
+    * @return a string representing the integer in base 16
+    */
+	static std::string ShortToHexString(short aInt);
+	/**
+    * Formats an 8-bit integer as a hex string
+    * @param aInt the integer to format
+    * @return a string representing the integer in base 16
+    */
+	static std::string CharToHexString(char aInt);
+
+	/**
+    * Converts a string to lower case
+    * @param aString the string to convert
+    * @return a version of the string in lower case
+    */
+	static std::string ToLower(const std::string& aString);
+	/**
+    * Converts a string to upper case
+    * @param aString the string to convert
+    * @return a version of the string in upper case
+    */
+	static std::string ToUpper(const std::string& aString);
+	/**
+    * Converts a string to C++ identifier format. Characters which are not
+	* valid C++ identifier characters are replaced with an underscore. If the
+	* string starts with a number or is empty, an underscore is added to the start.
+    * @param aString a string to convert to a C++ identifier
+    * @return the converted string
+    */
+	static std::string ToCpp(const std::string& aString);
+	/**
+    * Strips white-space from the start and end of the string
+    * @param aStr the string from which white space should be removed
+    */
+	static void StripLeadingAndTrailingWhitespace(std::string& aStr);
+
+	/**
+    * Is the character alphabetic?
+    * @param aChar the character to test
+    * @return true if the character is alphabetic
+    */
+	static bool IsAlpha(char aChar);
+	/**
+    * Is the character numeric?
+    * @param aChar the character to test
+    * @return true if the character is numeric
+    */
+	static bool IsNumeric(char aChar);
+	/**
+    * Is the character valid for a C++ identifier?
+    * @param aChar the character to test
+    * @return true if the character is valid for a C++ identifier
+    */
+	static bool IsCpp(char aChar);
+
+	/**
+    * This class contains a set of terms to replace in a string. It is used
+	* with CdlTkUtil::MultiReplace().
+    */
+	class CReplaceSet : public std::vector<CReplaceTerm>
+		{
+	public:
+		void Add(const std::string& aTarget, const std::string& aWith);
+		};
+	/**
+    * Replace a set of targets with other text in a string and return the result.
+    * @param aSet the set of pairs of targets and replacement text
+	* @param aIn the string to replace text in
+    * @return The result of the replacement
+    */
+	static std::string MultiReplace(const CReplaceSet& aSet, const std::string& aIn);
+	/**
+    * Replace a target in a string with some text and return the result.
+    * @param aTarget the text to replace
+    * @param aWith the text that replaces aTarget
+    * @param aIn the string in which to replace the text
+    * @return the result of the replacement
+    */
+	static std::string Replace(const std::string& aTarget, const std::string& aWith, const std::string& aIn);
+	/**
+    * Add a string to another. This function uses exponential growth of the target
+	* string to reduce average runtime for long sequences of appends to O(n log(n)).
+    * @param aTarget the string to which text is to be appended
+	* @param aAppend the text to append
+   */
+	static void AppendString(std::string& aTarget, const std::string& aAppend);
+
+	/**
+    * Remove and path components from a file name and path, and return the file name.
+    * @param aPath the path and filename
+    * @return the filename component of the path and filename passed in.
+    */
+	static std::string StripPath(const std::string& aPath);
+	/**
+    * Resolves a filename relative to a path, and returns the resulting resolved path
+    * @param aPath the path to which a relative filename is to be calculated
+	* @param aFileName the filename, possibly including relative path components
+	* such as . and .. which should be resolved.
+    * @return the resolved path and filename
+    */
+	static std::string ResolvePath(const std::string& aPath, const std::string& aFileName);
+	/**
+    * Converts a filename and path so that first letter of file name is capitalized
+	* and the rest is lower case
+    * @param aString the string to convert
+    * @return the converted filename and path
+    */
+	static std::string CapitalizeFilename(const std::string& aString);
+	/**
+    * Converts a filename and path to use the current standard for file name case
+    * @param aString the string to convert
+    * @return the converted filename and path
+    */
+	static std::string CorrectFilenameCase(const std::string& aString);
+
+	/**
+    * Opens a temporary output file, with a temporary file name.
+	* This function is normally used in conjunction with ExportFile() to ensure
+	* that files are only modified if they are changed.
+    * @param aStream the output stream to open
+	* @param aFile a file cleanup object which will contain the temporary file name
+	* and will remove the file on destruction
+    */
+	static void OpenTempOutput(std::ofstream& aStream, CCdlTkFileCleanup& aFile, std::ios_base::openmode aOpenMode = std::ios_base::out);
+	/**
+    * Opens an output file, throwing a CdlTkFileOpenErr exception if it fails.
+    * @param aStream the stream to open
+	* @param aFileName the name of the file to open
+    */
+	static void OpenOutput(std::ofstream& aStream, const std::string& aFileName, std::ios_base::openmode aOpenMode = std::ios_base::out);
+	/**
+    * Opens an input file, throwing a CdlTkFileOpenErr exception if it fails.
+    * @param aStream the stream to open
+	* @param aFileName the name of the file to open
+    */
+	static void OpenInput(std::ifstream& aStream, const std::string& aFileName, std::ios_base::openmode aOpenMode = std::ios_base::in);
+
+	/**
+    * Compares the source file with the destination. If they differ,
+	* it replaces the destination file with the source. The source file is removed.
+	* This function will throw a CdlTkFileOpenErr if the destination file
+	* is not writable. This function should be used when the destination file
+	* should not be modified manually.
+    * @param aSourceFile the temporary source file.
+    * @param aDestinationFileName the name of the destination file.
+    */
+	static void ExportFile(CCdlTkFileCleanup& aSourceFile, const std::string& aDestinationFileName, std::ios_base::openmode aOpenMode = 0);
+	/**
+    * Compares the source file with the destination. If they differ,
+	* it replaces the destination file with the source. The source file is removed.
+	* This function will report an error to the standard error stream if the
+	* destination file is not writable. This function should be used when the
+	* destination file may be modified manually, and may be under source control.
+    * @param aSourceFile the temporary source file.
+    * @param aDestinationFileName the name of the destination file.
+    */
+	static void ExportFileIfWritable(CCdlTkFileCleanup& aSourceFile, const std::string& aDestinationFileName, std::ios_base::openmode aOpenMode = 0);
+	/**
+    * Delete a file
+    * @param aFileName the name of the file to be deleted
+    */
+	static void DeleteFile(const std::string& aFileName);
+	/**
+    * Copies a file
+    * @param aSourceFileName the source file.
+    * @param aDestinationFileName the destination file.
+    */
+	static void CopyFile(const std::string& aSourceFileName, const std::string& aDestinationFileName, std::ios_base::openmode aOpenMode = 0);
+	/**
+    * Checks to see if two files are identical
+    * @param aLeftFileName one of the files to check
+    * @param aRightFileName the other file to check
+    */
+	static bool FilesAreIdentical(const std::string& aLeftFileName, const std::string& aRightFileName, std::ios_base::openmode aOpenMode = std::ios_base::in);
+
+	static void ReadFile(std::string& aContent, const std::string& aFileName);
+	static void WriteFile(const std::string& aContent, const std::string& aFileName);
+
+	template <class OutputIterator>
+	inline static void Tokenize(const std::string& aString, OutputIterator pOut)
+		{
+		const std::string ws(" \t\r\n");
+		std::string::const_iterator pChar = aString.begin();
+		std::string::const_iterator pWord = pChar;
+		for (; ; ++pChar)
+			{
+			if (pChar == aString.end() || ws.find_first_of(*pChar) != string::npos)
+				{
+				if (pWord != pChar)
+					{
+					*pOut = std::string(pWord, pChar);
+					pOut++;
+					}
+				pWord = pChar+1;
+				if (pChar == aString.end())
+					break;
+				}
+			}
+		}
+	};
+
+
+/**
+* This is the base class for all CDL Compiler Toolkit exceptions
+*/
+class CdlCompilerToolkitErr
+	{
+public:
+	/**
+    * destructor
+    */
+	virtual ~CdlCompilerToolkitErr();
+	/**
+    * virtual method for describing the exception on a stream
+    * @param stream the output stream for the exceptions description
+    */
+	virtual void Show(std::ostream& stream) const = 0;
+	};
+
+
+/**
+* This exception class is thrown for general assertions
+*/
+class CdlTkAssert : public CdlCompilerToolkitErr
+	{
+public:
+	/**
+    * constructor for a general assertion exception
+    * @param aText the assertion description
+    */
+	CdlTkAssert(const std::string& aText);
+	/**
+    * virtual method for describing the exception on a stream
+    * @param stream the output stream for the exceptions description
+    */
+	void Show(std::ostream& stream) const;
+private:
+	std::string iText;
+	};
+
+
+/**
+* This exception class is thrown for errors in opening a file
+*/
+class CdlTkFileOpenErr : public CdlCompilerToolkitErr
+	{
+public:
+	/**
+    * constructor for a file open exception
+    * @param aFileName the file that has failed to open
+    */
+	CdlTkFileOpenErr(const std::string& aFileName);
+	/**
+    * virtual method for describing the exception on a stream
+    * @param stream the output stream for the exceptions description
+    */
+	void Show(std::ostream& aStream) const;
+private:
+	std::string iFileName;
+	};
+
+
+/**
+* This class represents a temporary file. If an instance is destroyed, it will
+* delete the filename it has been given.
+*/
+class CCdlTkFileCleanup
+	{
+public:
+	/**
+    * default constructor
+    */
+	CCdlTkFileCleanup();
+	/**
+    * constructor which sets the filename for the temporary file
+    * @param aName the name for the file to be cleaned up
+    */
+	CCdlTkFileCleanup(const std::string& aName);
+	/**
+    * destructor
+	* This will delete the temporary file, if a filename has been set.
+    */
+	~CCdlTkFileCleanup();
+
+	/**
+    * Set the filename of the temporary file.
+    * @param aName the filename of the temporary file.
+    */
+	void Set(const std::string& aName);
+	/**
+    * Gets the filename of the temporary file.
+    * @return the filename.
+    */
+	std::string Name() const;
+	/**
+    * Deletes the temporary file and resets the filename.
+    */
+	void Cleanup();
+	/**
+    * Resets the filename so that no file will be deleted.
+    */
+	void Release();
+private:
+	std::string iName;
+	};
+
+
+}	// end of namespace CdlCompilerToolkit
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/cdl_api/inc/CdlDef.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* 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 "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:
+*
+*/
+
+#ifndef CDLDEF_H
+#define CDLDEF_H
+
+#define KCdlCompilerMajorVersion 1
+#define KCdlCompilerMinorVersion 0
+
+#define KCdlFlagRomOnlyValue 0x01
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,22 @@
+/*
+* 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 "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:  Includes all the SDK API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../cdl_api/group/bld.inf"
+#include "../layout_system_private_api/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/layout_system_private_api/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* 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 "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:  File that exports the files belonging to 
+:                Layout System Private API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/AknLayoutConsts.h     MW_LAYER_PLATFORM_EXPORT_PATH(AknLayoutConsts.h)
+../inc/AknLayoutByteCodes.h     MW_LAYER_PLATFORM_EXPORT_PATH(AknLayoutByteCodes.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/layout_system_private_api/inc/AknLayoutByteCodes.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef AKNLAYOUTBYTECODES_H
+#define AKNLAYOUTBYTECODES_H
+
+// the macro AKNLAYOUT_DEFINE_BYTECODE must come from any component that uses this header
+AKNLAYOUT_DEFINE_BYTECODE(KByteWord, 255)	// Treat the following 2 bytes as a signed 16-bit value
+AKNLAYOUT_DEFINE_BYTECODE(KByteEmpty, 254)	// The empty value.
+AKNLAYOUT_DEFINE_BYTECODE(KByteP1, 253)		// Use the next byte as an 8-bit signed offset from the parent value
+AKNLAYOUT_DEFINE_BYTECODE(KByteP2, 252)		// Use the next 2 bytes as a 16-bit signed offset from the parent value
+AKNLAYOUT_DEFINE_BYTECODE(KByteLong, 251)	// Treat the following 4 bytes as a signed 32-bit value
+
+#define KMaxSingleByteValue 250             // This value must be lower than the lowest ByteCode.
+#define KMaxDoubleByteValue 65535             // This value must be lower than the lowest ByteCode.
+#define KMinSingleByteParentRelativeValue -128
+#define KMaxSingleByteParentRelativeValue 127
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/layout_system_private_api/inc/AknLayoutConsts.h	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2005-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "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:  
+*
+*/
+
+
+#ifndef AKNLAYOUTCONSTS_H
+#define AKNLAYOUTCONSTS_H
+
+// Multiple number for hash algorithm. 131 was chosen because:
+// 1) It is prime.
+// 2) It is bigger than a typical ascii character.
+// These features should reduce the possibility of two names having
+// the same hash value.
+#define KAknLayoutScreenStyleNameHashMult 131
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_plat/layout_system_private_api/layout_system_private_api.metaxml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="79adf6078afb9e4b2acb8a931f5450dd" dataversion="1.0">
+  <name>Layout System Private API</name>
+  <description>Interfaces related to how the layout system works internally.</description>
+  <type>c++</type>
+  <subsystem>uitools</subsystem>
+  <libs>
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_pub/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,21 @@
+/*
+* 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 "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:  Includes all the SDK API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../third_party_bitmap_palette_api/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_pub/third_party_bitmap_palette_api/group/bld.inf	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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 "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:  File that exports the files belonging to 
+:                Third Party Bitmap Palette API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/ThirdPartyBitmap.pal     MW_LAYER_PUBLIC_EXPORT_PATH(ThirdPartyBitmap.pal)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_pub/third_party_bitmap_palette_api/inc/ThirdPartyBitmap.pal	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,256 @@
+0x00000000
+0x00CCFFFF
+0x0099FFFF
+0x0066FFFF
+0x0033FFFF
+0x0000FFFF
+0x00FFCCFF
+0x00CCCCFF
+0x0099CCFF
+0x0066CCFF
+0x0033CCFF
+0x0000CCFF
+0x00FF99FF
+0x00CC99FF
+0x009999FF
+0x006699FF
+0x003399FF
+0x000099FF
+0x00FF66FF
+0x00CC66FF
+0x009966FF
+0x006666FF
+0x003366FF
+0x000066FF
+0x00FF33FF
+0x00CC33FF
+0x009933FF
+0x006633FF
+0x003333FF
+0x000033FF
+0x00FF00FF
+0x00CC00FF
+0x009900FF
+0x006600FF
+0x003300FF
+0x000000FF
+0x00FFFFCC
+0x00CCFFCC
+0x0099FFCC
+0x0066FFCC
+0x0033FFCC
+0x0000FFCC
+0x00FFCCCC
+0x00CCCCCC
+0x0099CCCC
+0x0066CCCC
+0x0033CCCC
+0x0000CCCC
+0x00FF99CC
+0x00CC99CC
+0x009999CC
+0x006699CC
+0x003399CC
+0x000099CC
+0x00FF66CC
+0x00CC66CC
+0x009966CC
+0x006666CC
+0x003366CC
+0x000066CC
+0x00FF33CC
+0x00CC33CC
+0x009933CC
+0x006633CC
+0x003333CC
+0x000033CC
+0x00FF00CC
+0x00CC00CC
+0x009900CC
+0x006600CC
+0x003300CC
+0x000000CC
+0x00FFFF99
+0x00CCFF99
+0x0099FF99
+0x0066FF99
+0x0033FF99
+0x0000FF99
+0x00FFCC99
+0x00CCCC99
+0x0099CC99
+0x0066CC99
+0x0033CC99
+0x0000CC99
+0x00FF9999
+0x00CC9999
+0x00999999
+0x00669999
+0x00339999
+0x00009999
+0x00FF6699
+0x00CC6699
+0x00996699
+0x00666699
+0x00336699
+0x00006699
+0x00FF3399
+0x00CC3399
+0x00993399
+0x00663399
+0x00333399
+0x00003399
+0x00FF0099
+0x00CC0099
+0x00990099
+0x00660099
+0x00330099
+0x00000099
+0x00FFFF66
+0x00CCFF66
+0x0099FF66
+0x0066FF66
+0x0033FF66
+0x0000FF66
+0x00FFCC66
+0x00CCCC66
+0x0099CC66
+0x0066CC66
+0x0033CC66
+0x0000CC66
+0x00FF9966
+0x00CC9966
+0x00999966
+0x00669966
+0x00339966
+0x00009966
+0x00FF6666
+0x00CC6666
+0x00996666
+0x00666666
+0x00336666
+0x00006666
+0x00FF3366
+0x00CC3366
+0x00993366
+0x00663366
+0x00333366
+0x00003366
+0x00FF0066
+0x00CC0066
+0x00990066
+0x00660066
+0x00330066
+0x00000066
+0x00FFFF33
+0x00CCFF33
+0x0099FF33
+0x0066FF33
+0x0033FF33
+0x0000FF33
+0x00FFCC33
+0x00CCCC33
+0x0099CC33
+0x0066CC33
+0x0033CC33
+0x0000CC33
+0x00FF9933
+0x00CC9933
+0x00999933
+0x00669933
+0x00339933
+0x00009933
+0x00FF6633
+0x00CC6633
+0x00996633
+0x00666633
+0x00336633
+0x00006633
+0x00FF3333
+0x00CC3333
+0x00993333
+0x00663333
+0x00333333
+0x00003333
+0x00FF0033
+0x00CC0033
+0x00990033
+0x00660033
+0x00330033
+0x00000033
+0x00FFFF00
+0x00CCFF00
+0x0099FF00
+0x0066FF00
+0x0033FF00
+0x0000FF00
+0x00FFCC00
+0x00CCCC00
+0x0099CC00
+0x0066CC00
+0x0033CC00
+0x0000CC00
+0x00FF9900
+0x00CC9900
+0x00999900
+0x00669900
+0x00339900
+0x00009900
+0x00FF6600
+0x00CC6600
+0x00996600
+0x00666600
+0x00336600
+0x00006600
+0x00FF3300
+0x00CC3300
+0x00993300
+0x00663300
+0x00333300
+0x00003300
+0x00FF0000
+0x00CC0000
+0x00990000
+0x00660000
+0x00330000
+0x00000000
+0x00EEEEEE
+0x00DDDDDD
+0x00BBBBBB
+0x00AAAAAA
+0x00888888
+0x00777777
+0x00555555
+0x00444444
+0x00222222
+0x00111111
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00FFFFFF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uitools_pub/third_party_bitmap_palette_api/third_party_bitmap_palette_api.metaxml	Thu Dec 17 09:14:18 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="a51f299ab6fbc76b6f9f11fff944dddf" dataversion="1.0">
+  <name>Third Party Bitmap Palette API</name>
+  <description>Defines color values for the palette used with 3rd party bitmaps.</description>
+  <type>c++</type>
+  <subsystem>gfxtools</subsystem>
+  <libs>
+  </libs>
+  <release category="sdk" sinceversion="0.9"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>