From 64d370b7707ff9cca662b32f20061c7f67b65606 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 7 Aug 2018 21:49:18 +0200 Subject: [PATCH 1/4] [jnimarshalmethod-gen] Add -p|--profile option The new option allows to specify which types are processed by a *profile* with the list of types (regex patterns) to process. It is similar to specify multiple `-t` options. --- tools/jnimarshalmethod-gen/App.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/jnimarshalmethod-gen/App.cs b/tools/jnimarshalmethod-gen/App.cs index 23d488c7c..6d3ef24a4 100644 --- a/tools/jnimarshalmethod-gen/App.cs +++ b/tools/jnimarshalmethod-gen/App.cs @@ -93,6 +93,9 @@ List ProcessArguments (string [] args) { "h|help|?", "Show this message and exit", v => help = v != null }, + { "p|profile=", + "Generate marshaling methods only for types whose names match regex patterns listed in the {PROFILE} file. One pattern per line. Empty lines and lines starting with '#' character are ignored (comments).", + v => LoadProfile (v) }, { "t|type=", "Generate marshaling methods only for types whose names match {TYPE-REGEX}.", v => typeNameRegexes.Add (new Regex (v)) }, @@ -116,6 +119,24 @@ List ProcessArguments (string [] args) return assemblies; } + void LoadProfile (string profilePath) + { + try { + foreach (var line in File.ReadLines (profilePath)) { + if (string.IsNullOrWhiteSpace (line)) + continue; + + if (line [0] == '#') + continue; + + typeNameRegexes.Add (new Regex (line)); + } + } catch (Exception e) { + Error ($"Unable to read profile '{profilePath}'.\n{e}"); + Environment.Exit (4); + } + } + void ProcessAssemblies (List assemblies) { CreateJavaVM (jvmDllPath); From 7f8d65592de32a9866ba91c6614e3b7400619a27 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 9 Aug 2018 10:07:18 +0200 Subject: [PATCH 2/4] [jnimarshalmethod-gen] Use {Environment.NewLine} in the messages To look better in Windows environments. --- tools/jnimarshalmethod-gen/App.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/jnimarshalmethod-gen/App.cs b/tools/jnimarshalmethod-gen/App.cs index 6d3ef24a4..b8e4cdee4 100644 --- a/tools/jnimarshalmethod-gen/App.cs +++ b/tools/jnimarshalmethod-gen/App.cs @@ -132,7 +132,7 @@ void LoadProfile (string profilePath) typeNameRegexes.Add (new Regex (line)); } } catch (Exception e) { - Error ($"Unable to read profile '{profilePath}'.\n{e}"); + Error ($"Unable to read profile '{profilePath}'.{Environment.NewLine}{e}"); Environment.Exit (4); } } @@ -174,7 +174,7 @@ void ProcessAssemblies (List assemblies) try { CreateMarshalMethodAssembly (assembly); } catch (Exception e) { - Error ($"Unable to process assembly '{assembly}'\n{e.Message}\n{e}"); + Error ($"Unable to process assembly '{assembly}'{Environment.NewLine}{e.Message}{Environment.NewLine}{e}"); Environment.Exit (1); } } @@ -189,7 +189,7 @@ void CreateJavaVM (string jvmDllPath) try { builder.CreateJreVM (); } catch (Exception e) { - Error ($"Unable to create Java VM\n{e}"); + Error ($"Unable to create Java VM{Environment.NewLine}{e}"); Environment.Exit (3); } } From 09f4d0840c9753424f25ddf204cb83aa61c7c709 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 10 Aug 2018 10:01:35 -0400 Subject: [PATCH 3/4] Fix indentation. --- tools/jnimarshalmethod-gen/App.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/jnimarshalmethod-gen/App.cs b/tools/jnimarshalmethod-gen/App.cs index b8e4cdee4..f73ddf599 100644 --- a/tools/jnimarshalmethod-gen/App.cs +++ b/tools/jnimarshalmethod-gen/App.cs @@ -94,7 +94,7 @@ List ProcessArguments (string [] args) "Show this message and exit", v => help = v != null }, { "p|profile=", - "Generate marshaling methods only for types whose names match regex patterns listed in the {PROFILE} file. One pattern per line. Empty lines and lines starting with '#' character are ignored (comments).", + "Generate marshaling methods only for types whose names match regex patterns listed in the {PROFILE} file. One pattern per line. Empty lines and lines starting with '#' character are ignored (comments).", v => LoadProfile (v) }, { "t|type=", "Generate marshaling methods only for types whose names match {TYPE-REGEX}.", From 356e168a4ac3a9004fb00a29e9b361bd237fea3a Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Mon, 13 Aug 2018 15:13:31 -0400 Subject: [PATCH 4/4] Rename `--profile` to `--types` --- tools/jnimarshalmethod-gen/App.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/jnimarshalmethod-gen/App.cs b/tools/jnimarshalmethod-gen/App.cs index f73ddf599..56d10fc02 100644 --- a/tools/jnimarshalmethod-gen/App.cs +++ b/tools/jnimarshalmethod-gen/App.cs @@ -93,9 +93,11 @@ List ProcessArguments (string [] args) { "h|help|?", "Show this message and exit", v => help = v != null }, - { "p|profile=", - "Generate marshaling methods only for types whose names match regex patterns listed in the {PROFILE} file. One pattern per line. Empty lines and lines starting with '#' character are ignored (comments).", - v => LoadProfile (v) }, + { "types=", + "Generate marshaling methods only for types whose names match regex patterns listed {FILE}.\n" + + "One regex pattern per line.\n" + + "Empty lines and lines starting with '#' character are ignored as comments.", + v => LoadTypes (v) }, { "t|type=", "Generate marshaling methods only for types whose names match {TYPE-REGEX}.", v => typeNameRegexes.Add (new Regex (v)) }, @@ -119,10 +121,10 @@ List ProcessArguments (string [] args) return assemblies; } - void LoadProfile (string profilePath) + void LoadTypes (string typesPath) { try { - foreach (var line in File.ReadLines (profilePath)) { + foreach (var line in File.ReadLines (typesPath)) { if (string.IsNullOrWhiteSpace (line)) continue; @@ -132,7 +134,7 @@ void LoadProfile (string profilePath) typeNameRegexes.Add (new Regex (line)); } } catch (Exception e) { - Error ($"Unable to read profile '{profilePath}'.{Environment.NewLine}{e}"); + Error ($"Unable to read profile '{typesPath}'.{Environment.NewLine}{e}"); Environment.Exit (4); } }