Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b5eb04579aec
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ab556f7571cc
Choose a head ref
  • 15 commits
  • 7 files changed
  • 2 contributors

Commits on Mar 8, 2019

  1. none of this makes sense

    eggrobin committed Mar 8, 2019
    Copy the full SHA
    c841b49 View commit details
  2. it works

    eggrobin committed Mar 8, 2019
    Copy the full SHA
    29c5347 View commit details
  3. is_public

    eggrobin committed Mar 8, 2019
    Copy the full SHA
    9b48785 View commit details
  4. remove lamont_test

    eggrobin committed Mar 8, 2019
    Copy the full SHA
    64d1b2f View commit details
  5. remove traces

    eggrobin committed Mar 8, 2019
    Copy the full SHA
    f1b9e82 View commit details

Commits on Mar 9, 2019

  1. initialize

    eggrobin committed Mar 9, 2019
    Copy the full SHA
    00c5c0f View commit details
  2. after pleroy's review

    eggrobin committed Mar 9, 2019
    Copy the full SHA
    e7c29eb View commit details
  3. Copy the full SHA
    c57e2f7 View commit details
  4. Copy the full SHA
    105af68 View commit details
  5. Revert "remove lamont_test"

    This reverts commit 64d1b2f.
    eggrobin committed Mar 9, 2019
    Copy the full SHA
    482b58f View commit details
  6. it works

    eggrobin committed Mar 9, 2019
    Copy the full SHA
    72b03e9 View commit details
  7. remove lamont_test again

    eggrobin committed Mar 9, 2019
    Copy the full SHA
    fe4ef87 View commit details
  8. save the project file too

    eggrobin committed Mar 9, 2019
    Copy the full SHA
    dbdb773 View commit details

Commits on Mar 10, 2019

  1. messages

    eggrobin committed Mar 10, 2019
    Copy the full SHA
    0f41daf View commit details
  2. Merge pull request #2089 from eggrobin/lamont-test

    An interface that can actually be called
    pleroy authored Mar 10, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ab556f7 View commit details
73 changes: 73 additions & 0 deletions ksp_plugin_adapter/external_interface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Security.Authentication;

namespace principia {
namespace ksp_plugin_adapter {

public class ExternalInterface {
public XY GeopotentialGetCoefficient(int body_index, int degree, int order) {
ThrowOnError(
adapter_.Plugin().ExternalGeopotentialGetCoefficient(
body_index, degree, order, out XY result));
return result;
}

public double GeopotentialGetReferenceRadius(int body_index) {
ThrowOnError(
adapter_.Plugin().ExternalGeopotentialGetReferenceRadius(
body_index, out double result));
return result;
}

public static ExternalInterface Get() {
List<ScenarioModule> modules;
try {
modules = ScenarioRunner.GetLoadedModules();
} catch {
return null;
}
foreach (var module in modules) {
if (module is PrincipiaPluginAdapter) {
return new ExternalInterface((PrincipiaPluginAdapter)module);
}
}
return null;
}

private static void ThrowOnError(Status status) {
switch (status.error) {
case 0: return;
case 1: throw new OperationCanceledException("CANCELLED");
case 2: throw new Exception("UNKNOWN");
case 3: throw new ArgumentException("INVALID_ARGUMENT");
case 4: throw new TimeoutException("DEADLINE_EXCEEDED");
case 5: throw new KeyNotFoundException("NOT_FOUND");
case 6: throw new ArgumentException("ALREADY_EXISTS");
case 7: throw new UnauthorizedAccessException("PERMISSION_DENIED");
case 16: throw new AuthenticationException("UNAUTHENTICATED");
case 8: throw new Exception("RESOURCE_EXHAUSTED");
case 9: throw new Exception("FAILED_PRECONDITION");
case 10: throw new Exception("ABORTED");
case 11: throw new ArgumentOutOfRangeException("OUT_OF_RANGE");
case 12: throw new NotImplementedException("UNIMPLEMENTED");
case 13: throw new Exception("INTERNAL");
case 14: throw new Exception("UNAVAILABLE");
case 15: throw new Exception("DATA_LOSS");
default: throw new Exception($"Error {status.error}");
}
}

private ExternalInterface(PrincipiaPluginAdapter adapter) {
adapter_ = adapter;
if (!Loader.loaded_principia_dll_) {
throw new DllNotFoundException(
"The Principia native DLL failed to load");
}
}

private PrincipiaPluginAdapter adapter_;
}

} // namespace ksp_plugin_adapter
} // namespace principia
1 change: 0 additions & 1 deletion ksp_plugin_adapter/interface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace principia {
3 changes: 3 additions & 0 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -89,6 +89,9 @@ private enum UnityLayers {
private bool selecting_target_celestial_ = false;

private IntPtr plugin_ = IntPtr.Zero;
internal IntPtr Plugin() {
return plugin_;
}

private bool display_patched_conics_ = false;

11 changes: 9 additions & 2 deletions ksp_plugin_adapter/ksp_plugin_adapter.csproj
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
<ProjectGuid>{E75B3F05-D64F-4AFE-9493-2F94A9B37510}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ksp_plugin_adapter</RootNamespace>
<AssemblyName>ksp_plugin_adapter</AssemblyName>
<RootNamespace>principia.ksp_plugin_adapter</RootNamespace>
<AssemblyName>principia.ksp_plugin_adapter</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@@ -105,6 +105,7 @@
<Compile Include="differential_slider.cs" />
<Compile Include="disposable.cs" />
<Compile Include="disposable_marshaller.cs" />
<Compile Include="external_interface.cs" />
<Compile Include="flight_planner.cs" />
<Compile Include="gl_lines.cs" />
<Compile Include="interface.generated.cs" />
@@ -171,4 +172,10 @@
<Target Name="AfterBuild">
</Target>
-->
<Target Name="Rename" AfterTargets="AfterBuild">
<Move SourceFiles="$(TargetPath)" DestinationFiles="$(OutDir)$(ProjectName)$(TargetExt)" />
<Message Text="Renamed $(TargetPath) to $(OutDir)$(ProjectName)$(TargetExt)" Importance="high" />
<Move SourceFiles="$(OutDir)$(TargetName).pdb" DestinationFiles="$(OutDir)$(ProjectName).pdb" />
<Message Text="Renamed $(OutDir)$(TargetName).pdb to $(OutDir)$(ProjectName).pdb" Importance="high" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions ksp_plugin_adapter/loader.cs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ namespace principia {
namespace ksp_plugin_adapter {

internal static class Loader {
public static string LoadPrincipiaDllAndInitGoogleLogging() {
internal static string LoadPrincipiaDllAndInitGoogleLogging() {
if (loaded_principia_dll_) {
return null;
}
@@ -110,7 +110,7 @@ private static extern IntPtr dlopen(
[MarshalAs(UnmanagedType.LPTStr)] string filename,
int flags = RTLD_NOW);

private static bool loaded_principia_dll_ = false;
internal static bool loaded_principia_dll_ { get; private set; } = false;
}

} // namespace ksp_plugin_adapter
4 changes: 4 additions & 0 deletions serialization/journal.proto
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ message WXYZ {
}

message XY {
option (is_public) = true;
required double x = 1;
required double y = 2;
}
@@ -1969,6 +1970,9 @@ extend google.protobuf.MessageOptions {
// For an interchange message that is used as an in parameters, specifies the
// custom marshaler to use.
optional string in_custom_marshaler = 50011;
// For an interchange message, specifies whether the generated C# struct
// should be public (the default is internal).
optional bool is_public = 50012;
// If set, the body of the Run method is wrapped into an #ifdef for the given
// symbol. Useful for selectively skipping replay of some methods.
optional string run_conditional_compilation_symbol = 50010;
10 changes: 8 additions & 2 deletions tools/journal_proto_processor.cpp
Original file line number Diff line number Diff line change
@@ -947,9 +947,15 @@ void JournalProtoProcessor::ProcessInterchangeMessage(
cs_interface_type_declaration_[descriptor] =
"internal partial class " + name + " {\n";
} else {
MessageOptions const& message_options = descriptor->options();
std::string visibility = "internal";
if (message_options.HasExtension(journal::serialization::is_public)) {
CHECK(message_options.GetExtension(journal::serialization::is_public));
visibility = "public";
}
cs_interface_type_declaration_[descriptor] =
"[StructLayout(LayoutKind.Sequential)]\ninternal partial struct " +
name + " {\n";
"[StructLayout(LayoutKind.Sequential)]\n" + visibility +
" partial struct " + name + " {\n";
}
cxx_interface_type_declaration_[descriptor] =
"extern \"C\"\nstruct " + name + " {\n";