public void GeneratePackage(IProject project, PackageDescriptor pd) { string name = MakeIDName(pd.PackageName, pd); string fname = MakeVHDSourceFileName(name); string path = project.AddFile(fname); project.AddFileAttribute(fname, pd); if (pd.Library != null) project.SetFileLibrary(fname, pd.Library); MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms); IndentedTextWriter tw = new IndentedTextWriter(sw, " "); ClearDependencies(); tw.WriteLine("package " + name + " is"); tw.Indent++; GenerateTypeDecls(pd, tw); foreach (MethodDescriptor md in pd.GetActiveMethods()) { GenerateMethodDecl(md, tw); } foreach (FieldDescriptor fd in pd.GetConstants()) { DeclareField(fd, tw); } tw.Indent--; tw.WriteLine("end;"); tw.WriteLine(); tw.WriteLine("package body " + name + " is"); tw.Indent++; foreach (MethodDescriptor md in pd.GetActiveMethods()) { GenerateMethodImpl(md, tw); tw.WriteLine(); } tw.Indent--; tw.WriteLine("end package body;"); tw.Flush(); sw = new StreamWriter(path); tw = new IndentedTextWriter(sw, " "); CreateFileHeader(new GeneratorInfo(name), tw); GenerateDependencies(pd, tw); tw.Flush(); ms.Seek(0, SeekOrigin.Begin); ms.CopyTo(sw.BaseStream); ms.Close(); tw.Close(); sw.Close(); }
// TODO public void GeneratePackage(IProject project, PackageDescriptor pd) { string name = MakeIDName(pd.PackageName, pd); string fname = MakeSysCHeaderFileName(name); string path = project.AddFile(fname); project.AddFileAttribute(fname, pd); if (pd.Library != null) project.SetFileLibrary(fname, pd.Library); MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms); IndentedTextWriter tw = new IndentedTextWriter(sw, " "); string cfname = MakeSysCSourceFileName(name); string path1 = project.AddFile(cfname); project.AddFileAttribute(cfname, pd); if (pd.Library != null) project.SetFileLibrary(cfname, pd.Library); MemoryStream ms1 = new MemoryStream(); StreamWriter sw1 = new StreamWriter(ms1); IndentedTextWriter tw1 = new IndentedTextWriter(sw1, " "); ClearDependencies(); //tw.Indent++; tw1.WriteLine("#include \"" + fname + "\""); tw1.WriteLine(); GenerateTypeDecls(pd, tw); foreach (MethodDescriptor md in pd.GetMethods()) { GenerateMethodDecl(md, tw); tw.WriteLine(); GenerateMethodImpl(md, tw1); tw1.WriteLine(); } foreach (FieldDescriptor fd in pd.GetConstants()) { DeclareField(fd, tw); } tw.Indent--; //tw.Indent++; tw.WriteLine("#endif"); tw.Flush(); sw = new StreamWriter(path); tw = new IndentedTextWriter(sw, " "); tw1.Flush(); sw1 = new StreamWriter(path1); tw1 = new IndentedTextWriter(sw1, " "); CreateFileHeader(new GeneratorInfo(fname), tw); CreateFileHeader(new GeneratorInfo(cfname), tw1); GeneratePreProcDir(pd, tw); GenerateDependencies(pd, tw); //_extraLibraries.Add(new SysCLib(fname)); tw.Flush(); ms.Seek(0, SeekOrigin.Begin); ms.CopyTo(sw.BaseStream); ms.Close(); tw.Close(); sw.Close(); tw1.Flush(); ms1.Seek(0, SeekOrigin.Begin); ms1.CopyTo(sw1.BaseStream); ms1.Close(); tw1.Close(); sw1.Close(); }