Skip to content

Commit

Permalink
Add readme documentation, begin cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hallambaker committed Feb 24, 2019
1 parent 185d980 commit e1eeb62
Show file tree
Hide file tree
Showing 1,115 changed files with 75,834 additions and 15,352 deletions.
231 changes: 101 additions & 130 deletions ASN/Goedel.Tool.ASN/Asn2.cs

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions ASN/Goedel.Tool.ASN/AsnPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ public partial class Member {

bool Once = true;

private void SetFlags() {
Flags = (int) ((Optional ? ASNFlags.Optional : ASNFlags.Nil) |
private void SetFlags() => Flags = (int)((Optional ? ASNFlags.Optional : ASNFlags.Nil) |
(Implicit ? ASNFlags.Implicit : ASNFlags.Nil) |
(Explicit ? ASNFlags.Explicit : ASNFlags.Nil) |
(Context ? ASNFlags.Context : ASNFlags.Nil)
) ;
}
(Context ? ASNFlags.Context : ASNFlags.Nil)
);

public override void Complete() {
if (Once) {
Expand Down
66 changes: 28 additions & 38 deletions ASN/Goedel.Tool.ASN/GenerateCS.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Script Syntax Version: 1.0

// Unknown by Unknown
// Copyright © 2017 by
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -54,7 +54,7 @@ public void GenerateCS (ASN2 ASN2) {
_Output.Write ("\n{0}", _Indent);
_Output.Write ("\n{0}", _Indent);
_Output.Write ("// Generate OID declarations\n{0}", _Indent);
_Output.Write ("\n{0}", _Indent);
_Output.Write ("#pragma warning disable IDE0022\n{0}", _Indent);
_Output.Write ("namespace Goedel.ASN {{ // default namespace\n{0}", _Indent);
_Output.Write ("\n{0}", _Indent);
foreach (_Choice Toplevel in ASN2.Top) {
Expand Down Expand Up @@ -166,8 +166,7 @@ public void GenerateCS (ASN2 ASN2) {
_Output.Write (" /// <summary>\n{0}", _Indent);
_Output.Write (" /// The OID value\n{0}", _Indent);
_Output.Write (" /// </summary>\n{0}", _Indent);
_Output.Write (" public override int [] OID {{ \n{0}", _Indent);
_Output.Write (" get => Constants.OID__{1}; }} \n{0}", _Indent, Object.OID);
_Output.Write (" public override int [] OID => Constants.OID__{1}; \n{0}", _Indent, Object.OID);
_Output.Write ("\n{0}", _Indent);


Expand Down Expand Up @@ -217,8 +216,7 @@ public void GenerateCS (ASN2 ASN2) {
_Output.Write (" /// <summary>\n{0}", _Indent);
_Output.Write (" /// The OID value\n{0}", _Indent);
_Output.Write (" /// </summary>\n{0}", _Indent);
_Output.Write (" public override int [] OID {{ \n{0}", _Indent);
_Output.Write (" get => Constants.OID__{1}; }} \n{0}", _Indent, SingularObject.OID);
_Output.Write (" public override int [] OID => Constants.OID__{1}; \n{0}", _Indent, SingularObject.OID);
_Output.Write ("\n{0}", _Indent);
foreach (Member Member in SingularObject.Entries) {
EntryDeclaration (Member);
Expand Down Expand Up @@ -257,7 +255,7 @@ public void GenerateCS (ASN2 ASN2) {
}
}
_Output.Write (" }}\n{0}", _Indent);
_Output.Write ("\n{0}", _Indent);
_Output.Write ("#pragma warning restore IDE0022 \n{0}", _Indent);
}


Expand Down Expand Up @@ -352,32 +350,26 @@ public void TypeDeclaration (_Choice Type) {
break; }
}
}


//
// Encode
//
public void Encode (Member Member) {
Encode (Member.Name.ToString(), Member.Default, Member.Spec, Member.Flags, Member.Code);
}


//
// Decode
//
public void Decode (Member Member) {
Decode (Member.Name.ToString(), Member.Default, Member.Spec, Member.Flags, Member.Code);
}

//
// Encode
//
public void Encode(Member Member) => Encode(Member.Name.ToString(), Member.Default, Member.Spec, Member.Flags, Member.Code);

//
//
//

public void Encode (String Name, _Choice Spec, int Flags, int Code) {
Encode (Name, null, Spec, Flags, Code);
}
public void Encode (String Name, String Default, _Choice Spec, int Flags, int Code) {
//
// Decode
//
public void Decode(Member Member) => Decode(Member.Name.ToString(), Member.Default, Member.Spec, Member.Flags, Member.Code);


//
//
//

public void Encode(String Name, _Choice Spec, int Flags, int Code) => Encode(Name, null, Spec, Flags, Code);
public void Encode (String Name, String Default, _Choice Spec, int Flags, int Code) {
_Output.Write ("\n{0}", _Indent);
bool Call = false;
switch (Spec._Tag ()) {
Expand Down Expand Up @@ -511,17 +503,15 @@ public void Encode (String Name, String Default, _Choice Spec, int Flags, int Co
_Output.Write (" ({1}, {2}, {3});\n{0}", _Indent, Name, Flags, Code);
}
}



//
//
//

public void Decode (String Name, _Choice Spec, int Flags, int Code) {
Decode (Name, null, Spec, Flags, Code);
}
public void Decode (String Name, String Default, _Choice Spec, int Flags, int Code) {

//
//
//

public void Decode(String Name, _Choice Spec, int Flags, int Code) => Decode(Name, null, Spec, Flags, Code);
public void Decode (String Name, String Default, _Choice Spec, int Flags, int Code) {
_Output.Write ("\n{0}", _Indent);
bool Call = false;
switch (Spec._Tag ()) {
Expand Down
10 changes: 4 additions & 6 deletions ASN/Goedel.Tool.ASN/GenerateCS.script
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using Goedel.ASN;


// Generate OID declarations

##pragma warning disable IDE0022
namespace Goedel.ASN { // default namespace

#foreach (_Choice Toplevel in ASN2.Top)
Expand Down Expand Up @@ -114,8 +114,7 @@ namespace #{Cast.Name} {
/// <summary>
/// The OID value
/// </summary>
public override int [] OID {
get => Constants.OID__#{Object.OID}; }
public override int [] OID => Constants.OID__#{Object.OID};

#%
#foreach (Member Member in Object.Entries)
Expand Down Expand Up @@ -162,8 +161,7 @@ namespace #{Cast.Name} {
/// <summary>
/// The OID value
/// </summary>
public override int [] OID {
get => Constants.OID__#{SingularObject.OID}; }
public override int [] OID => Constants.OID__#{SingularObject.OID};

#foreach (Member Member in SingularObject.Entries)
#% EntryDeclaration (Member);
Expand Down Expand Up @@ -201,7 +199,7 @@ namespace #{Cast.Name} {
#end switchcast
#end foreach
}

##pragma warning restore IDE0022
#end method

#method EntryDeclaration Member Member
Expand Down
32 changes: 20 additions & 12 deletions ASN/asn2/ASN2.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -26,9 +26,8 @@ public partial class CommandLineInterpreter : CommandLineInterpreterBase {
/// <param name="Dispatch"></param>
/// <param name="args"></param>
/// <param name="index"></param>
public static void Help (DispatchShell Dispatch, string[] args, int index) {
public static void Help (DispatchShell Dispatch, string[] args, int index) =>
Brief(Description, DefaultCommand, Entries);
}

public static DescribeCommandEntry DescribeHelp = new DescribeCommandEntry() {
Identifier = "help",
Expand All @@ -42,19 +41,19 @@ public static void Help (DispatchShell Dispatch, string[] args, int index) {
/// <param name="Dispatch">The command description.</param>
/// <param name="args">The set of arguments.</param>
/// <param name="index">The first unparsed argument.</param>
public static void About (DispatchShell Dispatch, string[] args, int index) {
public static void About (DispatchShell Dispatch, string[] args, int index) =>
FileTools.About();
}


public static DescribeCommandEntry DescribeAbout = new DescribeCommandEntry() {
Identifier = "about",
HandleDelegate = About,
Entries = new List<DescribeEntry>() { }
};

static bool IsFlag(char c) {
return (c == UnixFlag) | (c == WindowsFlag) ;
}
static bool IsFlag(char c) =>
(c == UnixFlag) | (c == WindowsFlag) ;



static CommandLineInterpreter () {
Expand Down Expand Up @@ -89,13 +88,21 @@ static void Main(string[] args) {
public void MainMethod(string[] Args) {
ASN2Shell Dispatch = new ASN2Shell ();

MainMethod (Dispatch, Args);
try {
MainMethod (Dispatch, Args);
}
catch (Goedel.Command.ParserException) {
Brief(Description, DefaultCommand, Entries);
}
catch (System.Exception Exception) {
Console.WriteLine("Application: {0}", Exception.Message);
}
}


public void MainMethod(ASN2Shell Dispatch, string[] Args) {
public void MainMethod(ASN2Shell Dispatch, string[] Args) =>
Dispatcher (Entries, DefaultCommand, Dispatch, Args, 0);
} // Main




Expand All @@ -104,6 +111,7 @@ public static void Handle_Generate (
ASN2Shell Dispatch = DispatchIn as ASN2Shell;
Generate Options = new Generate ();
ProcessOptions (Args, Index, Options);
Dispatch._PreProcess (Options);
Dispatch.Generate (Options);
}

Expand Down Expand Up @@ -247,7 +255,7 @@ public virtual void Generate ( Generate Options) {
new FileStream(outputfile, FileMode.Create, FileAccess.Write)) {
using (TextWriter OutputWriter = new StreamWriter(outputStream, Encoding.UTF8)) {

Goedel.Tool.ASN.Generate Script = new Goedel.Tool.ASN.Generate (OutputWriter);
Goedel.Tool.ASN.Generate Script = new Goedel.Tool.ASN.Generate () { _Output= OutputWriter };

Script.GenerateCS (Parse);
}
Expand Down
9 changes: 9 additions & 0 deletions ASN/asn2/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"asn2": {
"commandName": "Project",
"commandLineArgs": "PKIX\\PKIX.asn2 /cs PKIX\\PKIX.cs",
"workingDirectory": "C:\\Users\\hallam\\Work\\mmm\\Libraries\\Goedel.Cryptography"
}
}
}
2 changes: 1 addition & 1 deletion ASN/asn2/VS.Make
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ToolTargets = \
ASN2.cs

ASN2.cs : ASN2.command
commandparse ASN2.command ASN2.cs
commandparse ASN2.command /cs ASN2.cs


prebuildRecurse :
Expand Down
Loading

0 comments on commit e1eeb62

Please sign in to comment.