Skip to content

Commit

Permalink
[invocation-overhead] Add generated source files (#1175)
Browse files Browse the repository at this point in the history
Building the `Java.Interop.sln` solution always produces some generated
files that `git` wants to try to commit:

	Changes not staged for commit:
	  (use "git add <file>..." to update what will be committed)
	  (use "git restore <file>..." to discard changes in working directory)
	        modified:   tests/invocation-overhead/jni.cs

	Untracked files:
	  (use "git add <file>..." to include in what will be committed)
	        tests/invocation-overhead/jni-api.h
	        tests/invocation-overhead/jni.c

Commit these generated files, and update the generator for `jni.cs` to
always use native platform new lines so it does not show up as modified
on Windows.
  • Loading branch information
jpobst authored Dec 11, 2023
1 parent 473ef74 commit d5afa0a
Show file tree
Hide file tree
Showing 3 changed files with 1,687 additions and 5 deletions.
10 changes: 5 additions & 5 deletions build-tools/jnienv-gen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static int Main (string [] args)

try {
using (TextWriter w = new StringWriter ()) {
w.NewLine = "\n";
w.NewLine = Environment.NewLine;
GenerateFile (w);
string content = w.ToString ();
if (jnienv_g_cs == "-")
Expand All @@ -50,7 +50,7 @@ public static int Main (string [] args)
}
using (TextWriter sw = new StringWriter ()) {
using (TextWriter hw = new StringWriter ()) {
sw.NewLine = "\n";
sw.NewLine = Environment.NewLine;
GenerateNativeLibSource (sw, hw, jnienv_g_h);
string sourceContent = sw.ToString ();
string headerContent = hw.ToString ();
Expand Down Expand Up @@ -254,13 +254,13 @@ static void GenerateJniNativeInterfaceInvoker (TextWriter o, HandleStyle style)
continue;
o.WriteLine ();
if (e.Prebind)
o.WriteLine ("\t\tpublic readonly {0} {1};\n", d, e.Name);
o.WriteLine ("\t\tpublic readonly {0} {1};{2}", d, e.Name, Environment.NewLine);
else {
o.WriteLine ("\t\t{0}? _{1};", d, e.Name);
o.WriteLine ("\t\tpublic {0} {1} {{", d, e.Name);
o.WriteLine ("\t\t\tget {");
o.WriteLine ("\t\t\t\tif (_{0} == null)\n\t\t\t\t\t{1}", e.Name, Initialize (e, "_", d));
o.WriteLine ("\t\t\t\treturn _{0};\n\t\t\t}}", e.Name);
o.WriteLine ("\t\t\t\tif (_{0} == null){2}\t\t\t\t\t{1}", e.Name, Initialize (e, "_", d), Environment.NewLine);
o.WriteLine ("\t\t\t\treturn _{0};{1}\t\t\t}}", e.Name, Environment.NewLine);
o.WriteLine ("\t\t}");
}
}
Expand Down
Loading

0 comments on commit d5afa0a

Please sign in to comment.