diff --git a/CSharpTranslator/antlr3/src/cs2j/CLR/TranslationTemplate.cs b/CSharpTranslator/antlr3/src/cs2j/CLR/TranslationTemplate.cs index ffd9e06..dbff816 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CLR/TranslationTemplate.cs +++ b/CSharpTranslator/antlr3/src/cs2j/CLR/TranslationTemplate.cs @@ -603,6 +603,9 @@ namespace RusticiSoftware.Translator.CLR [XmlElementAttribute("Name")] public string TypeName { get; set; } +// [XmlElementAttribute("Name")] +// public string[] TypeName { get; set; } + // Path to use when resolving types [XmlElementAttribute("Use")] public UseRepTemplate[] Uses { get; set; } diff --git a/CSharpTranslator/antlr3/src/cs2jTemplateGen/Main.cs b/CSharpTranslator/antlr3/src/cs2jTemplateGen/Main.cs index c33408b..4de730d 100644 --- a/CSharpTranslator/antlr3/src/cs2jTemplateGen/Main.cs +++ b/CSharpTranslator/antlr3/src/cs2jTemplateGen/Main.cs @@ -14,7 +14,6 @@ namespace cs2j.Template.Utils { private Assembly assembly = null; private int verbose = 0; - private List<string> extractTypes = new List<string>(); public TemplateFromDLL (string DLLFileName) { @@ -78,8 +77,18 @@ namespace cs2j.Template.Utils private void buildInterface(InterfaceRepTemplate iface, Type t) { iface.TypeName = TypeHelper.buildTypeName(t); + + List<String> bases = new List<String>(); + if (t.BaseType != null) + bases.Add(TypeHelper.buildTypeName(t.BaseType)); + foreach (Type iTy in t.GetInterfaces()) { + bases.Add(TypeHelper.buildTypeName(iTy)); + } + + iface.Inherits = bases.ToArray(); + // Grab Methods - foreach (MethodInfo m in t.GetMethods()) { + foreach (MethodInfo m in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) { MethodRepTemplate methRep = new MethodRepTemplate(); methRep.Name = m.Name; methRep.Return = TypeHelper.buildTypeName(m.ReturnType); @@ -123,10 +132,16 @@ namespace cs2j.Template.Utils } - private TypeRepTemplate mkTemplate(string typeName) { + private IList<TypeRepTemplate> mkTemplates(string typeName) { - TypeRepTemplate retRep = null; + List<TypeRepTemplate> rets = new List<TypeRepTemplate>(); Type t = assembly.GetType(typeName); + foreach (Type nestedTy in t.GetNestedTypes()) { + foreach(TypeRepTemplate nestedRep in mkTemplates(nestedTy.FullName)) { + rets.Add(nestedRep); + } + } + TypeRepTemplate retRep = null; if (t.IsClass) { ClassRepTemplate classRep = new ClassRepTemplate(); buildClass(classRep, t); @@ -145,7 +160,8 @@ namespace cs2j.Template.Utils } retRep = enumRep; } - return retRep; + rets.Add(retRep); + return rets; } @@ -205,23 +221,25 @@ namespace cs2j.Template.Utils foreach (string t in extractTypes) { if (templateDriver.verbose > 0) Console.WriteLine ( "extracting {0}", t ); - TypeRepTemplate tyRep = templateDriver.mkTemplate(t); + IList<TypeRepTemplate> tyReps = templateDriver.mkTemplates(t); TextWriter writer = null; - if (dumpXmls) { - string xmlFName = Path.Combine(xmlDir, t.Replace('.', Path.DirectorySeparatorChar) + ".xml"); - string xmlFDir = Path.GetDirectoryName(xmlFName); - if (!Directory.Exists(xmlFDir)) - { - Directory.CreateDirectory(xmlFDir); - } - writer = new StreamWriter(xmlFName); + foreach (TypeRepTemplate tyRep in tyReps) { + if (dumpXmls) { + string xmlFName = Path.Combine(xmlDir, tyRep.TypeName.Replace('.', Path.DirectorySeparatorChar) + ".xml"); + string xmlFDir = Path.GetDirectoryName(xmlFName); + if (!Directory.Exists(xmlFDir)) + { + Directory.CreateDirectory(xmlFDir); + } + writer = new StreamWriter(xmlFName); + } + else { + writer = Console.Out; + } + templateDriver.writeXmlStream(tyRep, writer); + if (dumpXmls) + writer.Close(); } - else { - writer = Console.Out; - } - templateDriver.writeXmlStream(tyRep, writer); - if (dumpXmls) - writer.Close(); } } } diff --git a/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj b/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj index 2b8adbc..12f7a1d 100644 --- a/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj +++ b/CSharpTranslator/antlr3/src/cs2jTemplateGen/cs2jTemplateGen.csproj @@ -1 +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)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>10.0.0</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{CC80B16E-0700-4AA5-ABA0-ADBCD9316952}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>cs2jTemplateGen</RootNamespace> <AssemblyName>cs2jTemplateGen</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</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Externalconsole>true</Externalconsole> <Commandlineparameters>-dll /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/src/cs2jTemplateGen/bin/Debug/NDesk.Options.dll NDesk.Options.OptionValueCollection</Commandlineparameters> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Externalconsole>true</Externalconsole> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Main.cs" /> <Compile Include="AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\cs2j\cs2j.csproj"> <Project>{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}</Project> <Name>cs2j</Name> </ProjectReference> <ProjectReference Include="..\NDesk.Options\NDesk.Options.csproj"> <Project>{E6ACBB37-AF38-45E1-B399-0CEE63809A15}</Project> <Name>NDesk.Options</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> \ No newline at end of file +<?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>{CC80B16E-0700-4AA5-ABA0-ADBCD9316952}</ProjectGuid> <OutputType>Exe</OutputType> <RootNamespace>cs2jTemplateGen</RootNamespace> <AssemblyName>cs2jTemplateGen</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</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Externalconsole>true</Externalconsole> <Commandlineparameters>-dll /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/src/cs2jTemplateGen/bin/Debug/NDesk.Options.dll NDesk.Options.OptionSet</Commandlineparameters> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Release</OutputPath> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <Externalconsole>true</Externalconsole> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Main.cs" /> <Compile Include="AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\cs2j\cs2j.csproj"> <Project>{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}</Project> <Name>cs2j</Name> </ProjectReference> <ProjectReference Include="..\NDesk.Options\NDesk.Options.csproj"> <Project>{E6ACBB37-AF38-45E1-B399-0CEE63809A15}</Project> <Name>NDesk.Options</Name> </ProjectReference> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> </Project> \ No newline at end of file