1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

Big, Interim Commit. Main thing here is Translation Template rewrite

This is in a half-broken state, but Translation Template is now more how I want it.

Major things for TranslationTemplate:

- re-org of classes to be better aligned with reality
- Value equality implemented (and days of my life wasted)
- Many collections are lists so that we can add to them as we parse code

Also:

- The start of a unit test suite (yay!)

-
This commit is contained in:
Kevin Glynn 2010-10-11 18:16:01 +02:00
parent b35194c4bc
commit 791c01efa5
13 changed files with 1832 additions and 667 deletions

View File

@ -1,16 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2j", "src\cs2j\cs2j.csproj", "{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr3.Runtime", "src\Antlr.Runtime\Antlr3.Runtime.csproj", "{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{79994BC6-E233-4F7F-B9E1-A137B34B3F99}"
ProjectSection(SolutionItems) = preProject
build.properties = build.properties
build.xml = build.xml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2jTest", "cs2jTest\cs2jTest.csproj", "{28A229C9-2F22-4384-B224-61A5C67638CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Default|Any CPU = Default|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{28A229C9-2F22-4384-B224-61A5C67638CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28A229C9-2F22-4384-B224-61A5C67638CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28A229C9-2F22-4384-B224-61A5C67638CE}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{28A229C9-2F22-4384-B224-61A5C67638CE}.Default|Any CPU.Build.0 = Debug|Any CPU
{28A229C9-2F22-4384-B224-61A5C67638CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28A229C9-2F22-4384-B224-61A5C67638CE}.Release|Any CPU.Build.0 = Release|Any CPU
{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -20,6 +35,11 @@ Global
{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = src\cs2j\cs2j.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection

View File

@ -1,27 +1,84 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" ctype="Workspace" />
<MonoDevelop.Ide.Workbench ActiveDocument="src/Antlr.Runtime/Antlr.Runtime.JavaExtensions/DictionaryExtensions.cs" ctype="Workbench">
<MonoDevelop.Ide.Workbench ActiveDocument="cs2jTest/TranslationTemplate.cs" ctype="Workbench">
<Files>
<File FileName="src/Antlr.Runtime/Antlr.Runtime/ANTLRInputStream.cs" Line="1" Column="1" />
<File FileName="src/cs2j/Utils/DirectoryHT.cs" Line="1" Column="1" />
<File FileName="src/cs2j/Utils/DirectoryHT.cs" Line="5" Column="43" />
<File FileName="src/Antlr.Runtime/Antlr.Runtime.JavaExtensions/DictionaryExtensions.cs" Line="78" Column="48" />
<File FileName="src/cs2j/CSharp/csCrawl.cs" Line="1" Column="1" />
<File FileName="src/cs2j/CLR/TranslationTemplate.cs" Line="601" Column="58" />
<File FileName="src/cs2j/CSharp/SignatureExtracter.cs" Line="11" Column="1" />
<File FileName="src/cs2j/CSharp/Main.cs" Line="14" Column="14" />
<File FileName="build.xml" Line="189" Column="35" />
<File FileName="build.properties" Line="18" Column="35" />
<File FileName="src/cs2j/CSharp/minDriver.cs" Line="20" Column="62" />
<File FileName="src/cs2j/CLR/TypeRep.cs" Line="902" Column="26" />
<File FileName="src/cs2j/CLR/cs2j.cs" Line="231" Column="56" />
<File FileName="cs2jTest/TranslationTemplate.cs" Line="70" Column="28" />
<File FileName="src/cs2j/Utils/Util.cs" Line="66" Column="35" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="Antlr3.Runtime" expanded="True">
<Node name="Antlr.Runtime.JavaExtensions" expanded="True" />
</Node>
<Node name="cs2j" expanded="True" selected="True">
<Node name="References" expanded="True" />
<Node name="cs2j" expanded="True">
<Node name="CLR" expanded="True" />
<Node name="CSharp" expanded="True" />
<Node name="Utils" expanded="True" />
</Node>
<Node name="cs2jTest" expanded="True">
<Node name="References" expanded="True" />
<Node name="TranslationTemplate.cs" selected="True" />
</Node>
</State>
</Pad>
<Pad Id="ClassPad">
<State expanded="True" selected="True" />
</Pad>
<Pad Id="MonoDevelop.Debugger.WatchPad">
<State />
</Pad>
<Pad Id="ConnectionManagerPad">
<State selected="True" />
</Pad>
<Pad Id="MonoDevelop.NUnit.TestPad">
<State expanded="True">
<Node name="cs2jTest" expanded="True">
<Node name="RusticiSoftware" expanded="True">
<Node name="Translator" expanded="True">
<Node name="CLR" expanded="True">
<Node name="TranslationTemplateTest" expanded="True">
<Node name="DelegateCase" selected="True" />
</Node>
</Node>
</Node>
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
<BreakpointStore>
<Breakpoint file="/Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/src/cs2j/TestFramework/TestFramework.cs" line="27" />
<Breakpoint file="/Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/src/cs2j/CSharp/Main.cs" line="11" />
<Breakpoint file="/Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/cs2jTest/TranslationTemplate.cs" line="70" />
</BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches ctype="PinnedWatchStore" />
<MonoDevelop.Ide.ItemProperties.cs2j ctype="Properties">
<MonoDevelop.Ide.CustomExecutionModes ctype="CustomExecutionModes">
<Data Name="tester" Id="a379c91f-9488-4a56-8f13-12f39f0c533b" ModeId="Default">
<CommandData>
<Item Key="MonoDevelop.Ide.Execution.CustomArgsCustomizer">
<Value Arguments="-testdrive" ctype="CustomArgsExecutionModeData">
<EnvironmentVariables />
</Value>
</Item>
<Item Key="MonoDevelop.Ide.Execution.MonoExecutionCustomizer">
<Value ctype="MonoExecutionParameters" />
</Item>
</CommandData>
</Data>
</MonoDevelop.Ide.CustomExecutionModes>
</MonoDevelop.Ide.ItemProperties.cs2j>
</Properties>

View File

@ -1,51 +1,45 @@
build.dir=${basedir}/build
svntx.build.dir=${build.dir}/svntx
cs2jtx.build.dir=${build.dir}/cs2jtx
cs2jtx.bin.dir=${cs2jtx.build.dir}/Translator/bin/Debug
svntxexe.svnwc.dir=${basedir}/
## build.properties for Production
## WARNING: If these boolean properties are shown through the launch dialog then
## we must deal with value == false
is.rebuild.cs2j=false
is.cs2j.svnwc=false
is.commit.javacode=false
build.dir=${basedir}/../build
svn.commit.msg.java=Auto-committed following cs2j translation
svn.commit.removed.msg.java=Auto-committed removed files following cs2j translation
svn.repo=https://svn.rusticisoftware.com/svn/projects
csharp.project=Products/ScormEngineNet
csharp.project.branch=trunk
csharp.tx.sub.dir=src/app/ScormEngine.Core
csharp.project.full=${csharp.project}/${csharp.project.branch}
csharpcode.branch.url=${svn.repo}/${csharp.project.full}/${csharp.tx.sub.dir}
csharptx.dir=ScormEngine.Core
csharpcode.dir=${svntx.build.dir}/${csharptx.dir}
csharpcode.tx.dir=${svntx.build.dir}/${csharptx.dir}/Logic
java.project=Products/ScormEngineJava
java.project.branch=${csharp.project.branch}
java.tx.sub.dir=RusticiSoftware.ScormContentPlayer.Logic/src
java.project.full=${java.project}/${java.project.branch}
javacode.branch.url=${svn.repo}/${java.project.full}/${java.tx.sub.dir}
javatx.dir=${java.tx.sub.dir}
javacode.svnwc.dir=${svntx.build.dir}/${javatx.dir}
javacode.old.svnwc.dir=${svntx.build.dir}/OldJava/${javatx.dir}
cs2j.project=Products/CS2JLibrary
#cs2j.project.branch=${csharp.project.branch}
cs2j.project.branch=trunk
cs2j.branch.url=${svn.repo}/${cs2j.project}/${cs2j.project.branch}/
cs2j.dir=${svntx.build.dir}/CS2JLibrary
cheats.dir=${svntx.build.dir}/Cheats
svn.exe=svn
builder.ant.lib=${basedir}/jar
builder.ant.lib=${basedir}/lib
builder.ant.dll=${basedir}/dll
## For Building cs2j
# Location of .Net on this machine (this is standard .Net 2.0 location)
windows.dotnet.release=v2.0.50727
windows.dotnet.dir=C:/WINDOWS/Microsoft.NET/Framework/${windows.dotnet.release}
# Location of antlr dlls on this machine
antlr.dll.dir=${builder.ant.dll}
cs2jtx.src.dir=${basedir}/src/cs2j
cs2jtx.bin.dir=${cs2jtx.src.dir}/bin/Debug
cs2jtx.build.dir=${build.dir}/cs2jtx
## For running cs2j
cs2jtx.exe= ${cs2jtx.bin.dir}/cs2j.exe
#cs2jtx.exe= ${basedir}/../bin/Translator.exe
# by default, sibling directory to Translator
cs2j.proj.dir=${basedir}/../../CS2JLibrary
cs2j.dir=${basedir}/../../CS2JLibrary/NetTranslations
cheats.dir=${basedir}/../../Cheats
# Directories to build into, against
# If no cs.app.dir set make it equal to cs.tx.dir
cs.app.dir=${cs.tx.dir}
# Object of the translation, by default in the build area
java.output.dir=${build.dir}/javaproject/src
cs2j.dist.dir=${build.dir}/cs2j/zip

View File

@ -1,15 +1,11 @@
<?xml-stylesheet type="text/xsl" href="file://C:\ant\etc\antex\antprettybuild\antprettybuild-3.1.1.xsl"?>
<project name="rusticiTranslator" default="launch" basedir="." xmlns:dn="antlib:org.apache.ant.dotnet">
<project name="cs2jTranslator" default="launch" basedir="." xmlns:dn="antlib:org.apache.ant.dotnet">
<description>
This script automates translation of a C# svn branch to a Java branch
</description>
<property file="${basedir}/launch.properties" />
<property file="${user.home}/${ant.project.name}.build.properties" />
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
This script builds the cs2j translator and translates C# code
</description>
<property name="builder.ant.lib" value="${basedir}/jar"/>
<!-- load the ant-dotnet task, see http://ant.apache.org/antlibs/dotnet/index.html -->
<taskdef uri="antlib:org.apache.ant.dotnet" resource="org/apache/ant/dotnet/antlib.xml" classpath="${builder.ant.lib}/ant-dotnet-1.0.jar" />
@ -17,193 +13,254 @@
<taskdef name="antform" classname="com.sardak.antform.AntForm" classpath="${builder.ant.lib}/antform.jar"/>
<taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpath="${builder.ant.lib}/antform.jar"/>
<target name="launch">
<antform title="C# to Java Translation" save="${basedir}/RusticiLogicTranslator/launch.properties">
<label>Enter a scratch directory to use for building</label>
<fileSelectionProperty label="build directory : " property="build.dir" directoryChooser="true" />
<separator />
<label>Enter the locations of the branches you want to translate from / to</label>
<target name="launch" depends="launch-form,run" description="Simple Graphical Launch"/>
<target name="launch-full" depends="launch-full-form,run" description="Graphical Launch with all options"/>
<target name="launch-form">
<property file="${basedir}/launch-simple.properties" />
<antform title="C# to Java Translation" save="${basedir}/launch-simple.properties">
<label>Configure the source and target locations for your translation:</label>
<fileSelectionProperty label="C# Translation Root : " property="cs.tx.dir" directoryChooser="true" />
<fileSelectionProperty label="Java Project src : " property="java.output.dir" directoryChooser="true" />
<separator />
<controlbar>
<button label="Cancel" type="cancel" target="cancel" newproject="false"/>
<button label="Reset" type="reset" />
<button label="OK" type="ok" focus="true" newproject="false"/>
</controlbar>
</antform>
</target>
<target name="launch-full-form">
<property file="${basedir}/launch-full.properties" />
<antform title="C# to Java Translation" save="${basedir}/launch-full.properties">
<label>Configure the source and target locations for your translation:</label>
<fileSelectionProperty label="C# Application Root : " property="cs.app.dir" directoryChooser="true" />
<fileSelectionProperty label="C# Translation Root : " property="cs.tx.dir" directoryChooser="true" />
<fileSelectionProperty label="Java output directory : " property="java.output.dir" directoryChooser="true" />
<fileSelectionProperty label="CS2J Translation Files : " property="cs2j.dir" directoryChooser="true" />
<separator />
<!-- <label>Enter the locations of the branches you want to translate from / to</label>
<textProperty label="ScormEngineNet branch : " property="csharp.project.full" />
<textProperty label="ScormEngineJava branch : " property="java.project.full" />
<separator />
<booleanProperty label="Commit Java code after translation " property="is.commit.javacode" />
<booleanProperty label="Refresh and Rebuild cs2j executable " property="is.rebuild.cs2j" />
<controlbar>
<button label="Cancel" type="cancel" target="cancel" newproject="false"/>
<button label="Reset" type="reset" />
<button label="OK" type="ok"/>
</controlbar>
</antform>
<antcall target="ok" />
</target>
-->
<controlbar>
<button label="Cancel" type="cancel" target="cancel" newproject="false"/>
<button label="Reset" type="reset" />
<button label="OK" type="ok" focus="true" newproject="false"/>
</controlbar>
</antform>
</target>
<target name="cancel">
<target name="cancel">
<echo message="Translation cancelled by user" />
<property name="is.run.cancelled" value="true" />
</target>
<target name="ok" unless="is.run.cancelled">
<!--antcall target="dumpProperties" inheritall="false" / -->
<antcall target="svntranslate" inheritall="false" />
<target name="ok">
</target>
<target name="run" depends="init,translateCS2J" unless="is.run.cancelled">
</target>
<!-- We could have left this in the msbuild script fed to buildTranslator, but it is clearer in Ant :) -->
<target name="antlrTranslator" depends="init" unless="is.run.cancelled">
<antlr target="${cs2jtx.src.dir}/UnicodeLexerBase.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpLexerBase.g" glib="${cs2jtx.src.dir}/UnicodeLexerBase.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpLexer.g" glib="${cs2jtx.src.dir}/UnicodeLexerBase.g;${cs2jtx.src.dir}/CSharpLexerBase.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpPreprocessorLexer.g" glib="${cs2jtx.src.dir}/UnicodeLexerBase.g;${cs2jtx.src.dir}/CSharpLexerBase.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpPreprocessorHooverLexer.g" glib="${cs2jtx.src.dir}/UnicodeLexerBase.g;${cs2jtx.src.dir}/CSharpLexerBase.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpParser.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpEnvBuilder.g">
<classpath> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/CSharpTranslator.g">
<classpath id="antlrjar"> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/NetTranslator.g">
<classpath id="antlrjar"> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
<antlr target="${cs2jtx.src.dir}/JavaPrettyPrinter.g">
<classpath id="antlrjar"> <pathelement location="${builder.ant.lib}/antlr.jar"/> </classpath>
</antlr>
</target>
<target name="svntranslate" description="translate a C# branch to a Java branch"
depends="clean,init,buildtranslator,checkoutCSharpJavaCode,translateCSharpToJava,setAddedFiles,commitAdded,setRemovedFiles,commitRemoved,commitJavaCode">
</target>
<!-- is.rebuild.cs2j can be set through launch window. rebuild iff var is set and not equal to false -->
<target name="-svn.rebuild.cs2j.check">
<condition property="internal.is.rebuild.cs2j">
<and>
<isset property="is.rebuild.cs2j" />
<not>
<equals arg1="${is.rebuild.cs2j}" arg2="false" />
</not>
</and>
</condition>
</target>
<target name="buildtranslator" depends="-svn.rebuild.cs2j.check" if="internal.is.rebuild.cs2j">
<antcall target="refreshtranslator" />
<ant antfile="build.xml" target="clean" />
<ant antfile="build.xml" target="buildTranslator" inheritall="true" />
</target>
<target name="refreshtranslator" if="is.cs2j.svnwc">
<dn:dotnetexec executable="${svn.exe}">
<arg value="update" />
<arg value="${svntxexe.svnwc.dir}" />
</dn:dotnetexec>
</target>
<target name="checkoutCSharpJavaCode" unless="is.donot.checkout.code">
<mkdir dir="${csharpcode.dir}" />
<delete failonerror="true" dir="${csharpcode.dir}" />
<mkdir dir="${javacode.svnwc.dir}" />
<delete failonerror="true" dir="${javacode.svnwc.dir}" />
<mkdir dir="${javacode.old.svnwc.dir}" />
<delete failonerror="true" dir="${javacode.old.svnwc.dir}" />
<dn:dotnetexec executable="${svn.exe}">
<arg value="export" />
<arg value="${csharpcode.branch.url}" />
<arg value="${csharpcode.dir}" />
</dn:dotnetexec>
<dn:dotnetexec executable="${svn.exe}">
<arg value="checkout" />
<arg value="${javacode.branch.url}" />
<arg value="${javacode.svnwc.dir}" />
</dn:dotnetexec>
</target>
<target name="checkoutCS2JProject" unless="is.donot.checkout.code">
<mkdir dir="${cs2j.dir}" />
<delete failonerror="true" dir="${cs2j.dir}" />
<dn:dotnetexec executable="${svn.exe}">
<arg value="export" />
<arg value="${cs2j.branch.url}" />
<arg value="${cs2j.dir}" />
</dn:dotnetexec>
</target>
<target name="makeCopyJavaCode">
<copy todir="${javacode.old.svnwc.dir}">
<fileset dir="${javacode.svnwc.dir}" defaultexcludes="false" />
</copy>
</target>
<!-- C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /defin
e:DEBUG;TRACE /reference:C:\cygwin\antlr\build\lib\antlr.astframe.dll /reference:C:\cygwin\antlr\build\lib\antlr.runtime
.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framew
ork\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C
:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /debug:full /optimize- /out:obj\Debug\Translator.exe
/target:exe
-->
<target name="translateCSharpToJava" depends="buildtranslator,checkoutCS2JProject,checkoutCSharpJavaCode,makeCopyJavaCode">
<!-- Delete existing java files, they will be recreated by the translation if neccessary -->
<delete dir="${javacode.svnwc.dir}">
<include name="**/*.java" />
</delete>
<ant antfile="build.xml" target="translateCS2J">
<!-- There are no cheats -->
<property name="cheats.dir" value="${cheats.dir}" />
<property name="cs.app.dir" value="${csharpcode.dir}" />
<property name="java.output.dir" value="${javacode.svnwc.dir}" />
<property name="cs.tx.dir" value="${csharpcode.tx.dir}" />
</ant>
</target>
<target name="buildTranslator" depends="antlrTranslator" description="Builds CSharp to Java Translator" unless="is.run.cancelled">
<mkdir dir="${cs2jtx.bin.dir}/"/>
<dn:msbuild>
<dn:build>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<!-- I am just mimicing the standard build options used by VS2005 here -->
<Csc Sources="@(Compile)" References="@(Reference)" TargetType="exe"
OutputAssembly="${cs2jtx.bin.dir}/Translator.exe"
Optimize="false"
DebugType="full"
DisabledWarnings="1701,1702"
EmitDebugInformation="true"
ErrorReport="prompt"
NoConfig="true"
Warninglevel="4" />
</Target>
<ItemGroup>
<Reference Include="${antlr.dll.dir}/antlr.astframe.dll" />
<Reference Include="${antlr.dll.dir}/antlr.runtime.dll" />
<Reference Include="${windows.dotnet.dir}/System.dll" />
<Reference Include="${windows.dotnet.dir}/System.Data.dll" />
<Reference Include="${windows.dotnet.dir}/System.Windows.Forms.dll" />
<Reference Include="${windows.dotnet.dir}/System.Xml.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="${cs2jtx.src.dir}\ASTNode.cs" />
<Compile Include="${cs2jtx.src.dir}\ASTNodeFactory.cs" />
<Compile Include="${cs2jtx.src.dir}\CodeMaskEnums.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpEnvBuilder.cs" />
<Compile Include="${cs2jtx.src.dir}\DirectoryHT.cs" />
<Compile Include="${cs2jtx.src.dir}\SigEnv.cs" />
<Compile Include="${cs2jtx.src.dir}\TranslationTemplate.cs" />
<Compile Include="${cs2jtx.src.dir}\TypeTable.cs" />
<Compile Include="${cs2jtx.src.dir}\NetTranslatorBase.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpHooverTokenTypes.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpJavaTokenTypes.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpLexer.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpLexerBase.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpLexerBaseTokenTypes.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpLexerTokenTypes.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpParser.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpPreprocessorHooverLexer.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpPreprocessorLexer.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpPreprocessTokenTypes.cs" />
<Compile Include="${cs2jtx.src.dir}\CustomHiddenStreamToken.cs" />
<Compile Include="${cs2jtx.src.dir}\CSharpTranslator.cs" />
<Compile Include="${cs2jtx.src.dir}\Exception.cs" />
<Compile Include="${cs2jtx.src.dir}\JavaPrettyPrinter.cs" />
<Compile Include="${cs2jtx.src.dir}\JavaTreeParser.cs" />
<Compile Include="${cs2jtx.src.dir}\Main.cs" />
<Compile Include="${cs2jtx.src.dir}\NetTranslator.cs" />
<Compile Include="${cs2jtx.src.dir}\Properties\AssemblyInfo.cs" />
<Compile Include="${cs2jtx.src.dir}\Set.cs" />
<Compile Include="${cs2jtx.src.dir}\SymbolTable.cs" />
<Compile Include="${cs2jtx.src.dir}\TypeRep.cs" />
<Compile Include="${cs2jtx.src.dir}\UnicodeLexerBase.cs" />
<Compile Include="${cs2jtx.src.dir}\UnicodeLexerBaseTokenTypes.cs" />
</ItemGroup>
</Project>
</dn:build>
</dn:msbuild>
<copy file="${antlr.dll.dir}/antlr.astframe.dll" todir="${cs2jtx.bin.dir}"/>
<copy file="${antlr.dll.dir}/antlr.runtime.dll" todir="${cs2jtx.bin.dir}"/>
</target>
<!-- is.commit.javacode can be set through launch window. rebuild iff var is set and not equal to false -->
<target name="-svn.commit.javacode.check">
<condition property="internal.is.commit.javacode">
<and>
<isset property="is.commit.javacode" />
<not>
<equals arg1="${is.commit.javacode}" arg2="false" />
</not>
</and>
</condition>
</target>
<!-- "C:\Documents and Settings\kevin.glynn\My Documents\Visual Studio
2005\Projects\Translator\Translator\bin\Debug\Translator.exe" -dumpxml
-odir "C:\Documents and
Settings\kevin.glynn\eclipsews\RusticiSoftware.ScormUntethered.Logic\src"
-netdir "c:\Documents and Settings\kevin.glynn\eclipsews\CS2JLibrary"
-appdir "c:\docume~1\kevin~1.gly\locals~1\temp\tmpk6_pcn" -cheatdir
"c:\Documents and Settings\kevin.glynn\My Documents\Cheats"
"c:\docume~1\kevin~1.gly\locals~1\temp\tmpk6_pcn\UntetheredLogic" -->
<target name="translateCS2J" depends="init" description="run translator" unless="is.run.cancelled">
<dn:dotnetexec executable="${cs2jtx.exe}">
<arg value="-mindriver"/>
<arg value="-version"/>
<arg value="-v"/>
<arg value="-dumpxml"/>
<arg value="-xmldir"/>
<arg file="${cs2jtx.build.dir}/xmls"/>
<arg value="-dumpenums"/>
<arg file="${cs2jtx.build.dir}/enums.xml"/>
<arg value="-cheatdir"/>
<arg file="${cheats.dir}"/>
<arg value="-netdir"/>
<arg file="${cs2j.dir}"/>
<arg value="-exnetdir"/>
<arg file="${cs2j.dir}/build.xml"/>
<arg value="-appdir"/>
<arg file="${cs.app.dir}"/>
<arg value="-odir"/>
<arg file="${java.output.dir}"/>
<arg file="${cs.tx.dir}" />
</dn:dotnetexec>
</target>
<target name="commitJavaCode" depends="-svn.commit.javacode.check" if="internal.is.commit.javacode">
<dn:dotnetexec executable="${svn.exe}">
<arg value="commit" />
<arg value="--message" />
<arg value="${svn.commit.msg.java}" />
<arg value="${javacode.svnwc.dir}" />
</dn:dotnetexec>
</target>
<target name="dumpProperties" description="output all set properties, a useful sanity check">
<target name="dumpProperties" depends="init" description="output all set properties, a useful sanity check">
<echoproperties />
</target>
<target name="init" depends="">
<mkdir dir="${svntx.build.dir}" />
<target name="init" depends="" unless="is.run.cancelled">
<property file="${user.home}/${ant.project.name}.build.properties" />
<property file="${user.home}/build.properties" />
<property file="build.properties" />
<mkdir dir="${cs2jtx.build.dir}" />
</target>
<target name="clean" depends="" description="clean out build area">
<!-- create dir if it doesn't exist, so delete only fails if there is a real problem -->
<mkdir dir="${svntx.build.dir}"/>
<delete failonerror="true" dir="${svntx.build.dir}" />
</target>
<target name="clean" depends="init" description="clean out build area">
<!-- create dir if it doesn't exist, so delete only fails if there is a real problem -->
<mkdir dir="${build.dir}"/>
<delete failonerror="true" dir="${build.dir}" />
<mkdir dir="${cs2jtx.build.dir}"/>
<delete failonerror="true" dir="${cs2jtx.build.dir}" />
</target>
<target name="setAddedFiles">
<pathconvert property="svn.added.files" pathsep='" "' setonempty="false">
<fileset dir="${javacode.svnwc.dir}" includes="**/*.java" id="java.added.fileset">
<present present="srconly" targetdir="${javacode.old.svnwc.dir}" />
</fileset>
</pathconvert>
</target>
<target name="commitAdded" if="svn.added.files">
<dn:dotnetexec executable="${svn.exe}">
<arg value="add" />
<arg value='"${svn.added.files}"' />
</dn:dotnetexec>
</target>
<target name="setRemovedFiles">
<pathconvert property="svn.removed.files" pathsep='" "' setonempty="false">
<fileset dir="${javacode.old.svnwc.dir}" includes="**/*.java" id="java.removed.fileset">
<present present="srconly" targetdir="${javacode.svnwc.dir}" />
</fileset>
</pathconvert>
</target>
<!-- We only remove files from subversion if there are files to remove and is.commit.javacode is set -->
<target name="-svn.remove.files.check" depends="-svn.commit.javacode.check">
<condition property="is.svn.remove.files">
<and>
<isset property="svn.removed.files"/>
<isset property="internal.is.commit.javacode"/>
</and>
</condition>
</target>
<target name="commitRemoved" depends="-svn.remove.files.check" if="is.svn.remove.files">
<dn:dotnetexec executable="${svn.exe}">
<arg value="remove" />
<arg value='"${svn.removed.files}"' />
</dn:dotnetexec>
<dn:dotnetexec executable="${svn.exe}">
<arg value="commit" />
<arg value="--message" />
<arg value="${svn.commit.removed.msg.java}" />
<arg value="${javacode.old.svnwc.dir}" />
</dn:dotnetexec>
</target>
<target name="dist" depends="buildTranslator" description="Make a distribution of cs2j">
<fail message="You must set the distribution version number (cs2j.dist.version)" unless="cs2j.dist.version" />
<fail message="You must set the directory containing documentation (cs2j.doc.dir)" unless="cs2j.doc.dir" />
<delete failonerror="false" dir="${build.dir}/cs2j" />
<mkdir dir="${build.dir}/cs2j" />
<mkdir dir="${cs2j.dist.dir}" />
<echo message="do dist :) ${cs2jtx.exe}" />
<property name="cs2j.pack.dir" value="${build.dir}/cs2j/pack/cs2j_${cs2j.dist.version}/" />
<!-- cs2j executable -->
<copy todir="${cs2j.pack.dir}/Bin/">
<fileset dir="${cs2jtx.bin.dir}" excludes="*.vshost.exe*"/>
</copy>
<copy todir="${cs2j.pack.dir}/lib/">
<fileset dir="./lib" excludes="antlr.jar"/>
</copy>
<copy todir="${cs2j.pack.dir}">
<fileset dir="${cs2j.doc.dir}" />
</copy>
<copy todir="${cs2j.pack.dir}" file="./build.xml" />
<copy todir="${cs2j.pack.dir}" file="./dist/build.properties" />
<copy todir="${cs2j.pack.dir}/CS2JLibrary">
<fileset dir="${cs2j.proj.dir}">
<include name="src/**/*" />
<include name="LICENSE" />
<include name="NOTICE" />
<include name="build.*" />
<include name=".project" />
<include name=".classpath" />
<include name="lib/*" />
<include name="NetTranslations/**/*" />
</fileset>
</copy>
<zip destfile="${cs2j.dist.dir}/cs2j_${cs2j.dist.version}.zip" basedir="${cs2j.pack.dir}/../" />
</target>
</project>

View File

@ -0,0 +1,76 @@
using System;
using NUnit.Framework;
using System.IO;
using System.Xml.Serialization;
using RusticiSoftware.Translator.Utils;
using System.Xml;
using System.Text;
using System.Collections.Generic;
namespace RusticiSoftware.Translator.CLR
{
[TestFixture()]
public class TranslationTemplateTest
{
private TypeRepTemplate ToStreamAndBack(TypeRepTemplate inT) {
XmlSerializer xmls = new XmlSerializer(inT.GetType(), Constants.TranslationTemplateNamespace);
using (MemoryStream ms = new MemoryStream())
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
settings.Indent = true;
settings.IndentChars = "\t";
settings.NewLineChars = Environment.NewLine;
settings.ConformanceLevel = ConformanceLevel.Document;
using (XmlWriter writer = XmlTextWriter.Create(ms, settings))
{
xmls.Serialize(writer, inT);
}
#if VERBOSETESTS
string xml = Encoding.UTF8.GetString(ms.ToArray());
Console.WriteLine (xml);
#endif
//ms.Flush();
ms.Position = 0;
return TypeRepTemplate.newInstance(ms);
}
}
[Test()]
public void EnumCase ()
{
EnumRepTemplate to = new EnumRepTemplate();
to.Members.Add(new EnumMemberRepTemplate("START"));
to.Members.Add(new EnumMemberRepTemplate("EOF","3"));
EnumRepTemplate back = (EnumRepTemplate)ToStreamAndBack(to);
Assert.AreEqual(to, back);
}
[Test()]
public void DelegateCase ()
{
DelegateRepTemplate to = new DelegateRepTemplate();
to.Return = "System.String";
to.Params.Add(new ParamRepTemplate("System.Int32", "count"));
to.Params.Add(new ParamRepTemplate("System.Object", "fill"));
to.Params.Add(new ParamRepTemplate("System.Boolean", "verbose"));
to.Java = "fred";
DelegateRepTemplate back = (DelegateRepTemplate)ToStreamAndBack(to);
Assert.AreEqual(to, back);
}
}
}

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{28A229C9-2F22-4384-B224-61A5C67638CE}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>cs2jTest</RootNamespace>
<AssemblyName>cs2jTest</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG VERBOSETESTS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.core, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
<Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TranslationTemplate.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\cs2j\cs2j.csproj">
<Project>{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}</Project>
<Name>cs2j</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Default</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ItemType>NUnitAssemblyGroupProject</ItemType> <ProductVersion>10.0.0</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CBDDA73A-AA2C-42D1-A7D6-F3DE6F1EE2FC}</ProjectGuid> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Default|AnyCPU' " /> </Project>

File diff suppressed because it is too large Load Diff

View File

@ -102,8 +102,8 @@ namespace RusticiSoftware.Translator.CLR
public ConstructorRep(ConstructorRepTemplate ct, ICollection pth)
{
Params = new ParamRep[ct.Params.Length];
for (int i = 0; i < ct.Params.Length; i++)
Params = new ParamRep[ct.Params.Count];
for (int i = 0; i < ct.Params.Count; i++)
{
Params[i] = ParamRep.newInstance(ct.Params[i], pth);
}
@ -253,7 +253,7 @@ namespace RusticiSoftware.Translator.CLR
{
Name = ft.Name;
Type = TypeRep.newInstance(ft.Type, pth);
Get = ft.Get;
Get = ft.Java;
Imports = new string[ft.Imports.Length];
for (int i = 0; i < ft.Imports.Length; i++)
{
@ -274,7 +274,7 @@ namespace RusticiSoftware.Translator.CLR
public PropRep(PropRepTemplate pt, ICollection pth) : base(pt, pth)
{
Set = pt.Set;
Set = pt.JavaSet;
}
@ -387,11 +387,11 @@ namespace RusticiSoftware.Translator.CLR
public virtual void Build(TypeRepTemplate template)
{
ICollection uPath = template.NamespacePath;
ICollection uPath = template.Uses;
TypeName = template.TypeName;
Java = template.Java;
/*
Imports = new string[template.Imports.Length];
for (int i = 0; i < template.Imports.Length; i++)
{
@ -448,7 +448,8 @@ namespace RusticiSoftware.Translator.CLR
ms.Add(new MethodRep(mt, uPath));
MethodsD[mt.Name] = ms;
}
}
*/
}
private static ClassRep newInstance(ClassRepTemplate template)
{
@ -752,20 +753,20 @@ namespace RusticiSoftware.Translator.CLR
public ClassRep(ClassRepTemplate template)
: base(template)
{
Constructors = new ConstructorRep[template.Constructors.Length];
for (int i = 0; i < template.Constructors.Length; i++)
Constructors = new ConstructorRep[template.Constructors.Count];
for (int i = 0; i < template.Constructors.Count; i++)
{
Constructors[i] = new ConstructorRep(template.Constructors[i], template.NamespacePath);
Constructors[i] = new ConstructorRep(template.Constructors[i], template.Uses);
}
}
public override void Build(TypeRepTemplate template)
{
ClassRepTemplate ctemp = (ClassRepTemplate)template;
Constructors = new ConstructorRep[ctemp.Constructors.Length];
for (int i = 0; i < ctemp.Constructors.Length; i++)
Constructors = new ConstructorRep[ctemp.Constructors.Count];
for (int i = 0; i < ctemp.Constructors.Count; i++)
{
Constructors[i] = new ConstructorRep(ctemp.Constructors[i], ctemp.NamespacePath);
Constructors[i] = new ConstructorRep(ctemp.Constructors[i], ctemp.Uses);
}
base.Build(template);
@ -846,18 +847,18 @@ namespace RusticiSoftware.Translator.CLR
public EnumRep(EnumRepTemplate template)
: base(template)
{
int numfields = template.Fields.Length;
int numfields = template.Members.Count;
fieldsA = new string[numfields];
for (int i = 0; i < numfields; i++)
fieldsA[i] = template.Fields[i].Name;
fieldsA[i] = template.Members[i].Name;
}
public override void Build(TypeRepTemplate template)
public void Build(EnumRepTemplate template)
{
int numfields = template.Fields.Length;
int numfields = template.Members.Count;
fieldsA = new string[numfields];
for (int i = 0; i < numfields; i++)
fieldsA[i] = template.Fields[i].Name;
fieldsA[i] = template.Members[i].Name;
base.Build(template);
}
@ -885,6 +886,30 @@ namespace RusticiSoftware.Translator.CLR
{
}
public override void Build(TypeRepTemplate template)
{
base.Build(template);
}
}
public class DelegateRep : TypeRep
{
public DelegateRep()
: base()
{ }
// Dummy Delegate
public DelegateRep(string name)
: base(name)
{
}
public DelegateRep(DelegateRepTemplate template)
: base(template)
{
}
public override void Build(TypeRepTemplate template)
{
base.Build(template);

View File

@ -1,9 +1,9 @@
using System;
using Path = System.IO.Path;
using Antlr.Runtime;
namespace RusticiSoftware.Translator.CSharp
{
using System;
using Path = System.IO.Path;
using Antlr.Runtime;
public class Driver
{
public static void Main(string[] args)

View File

@ -14,7 +14,10 @@ namespace RusticiSoftware.Translator.CSharp
{
if (args.Length > 0)
{
string inputFileName = args[1];
// Just take last argument so that we ignore any passed options
string inputFileName = args[args.Length - 1];
if (!Path.IsPathRooted(inputFileName))
{
inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);

View File

@ -0,0 +1,9 @@
using System;
namespace RusticiSoftware.Translator.Utils
{
public static class Constants
{
public const string TranslationTemplateNamespace="urn:www.twigletsoftware.com:schemas:txtemplate:1:0";
}
}

View File

@ -39,6 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Commandlineparameters>-testdrive</Commandlineparameters>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -63,6 +64,7 @@
<Compile Include="CSharp\SignatureExtracter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\DirectoryHT.cs" />
<Compile Include="Utils\Constants.cs" />
</ItemGroup>
<ItemGroup>
<None Include="CSharp\SignatureExtracter.g" />