From a7a224ff61a42c3e69a9095862fb6afefc6a8398 Mon Sep 17 00:00:00 2001 From: pillowtrucker Date: Fri, 17 May 2024 15:59:52 +0200 Subject: [PATCH] getting more desperate lol --- csrc/Therac.c | 28 +++++++++++++++++++++++ csrc/Therac.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ hstherac25.cabal | 3 ++- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 csrc/Therac.c create mode 100644 csrc/Therac.h diff --git a/csrc/Therac.c b/csrc/Therac.c new file mode 100644 index 0000000..28b544c --- /dev/null +++ b/csrc/Therac.c @@ -0,0 +1,28 @@ +#include "Therac.h" +#include "HsFFI.h" +#include +HsStablePtr start_machine() { + + char * argv[4] = {(char *)"-threaded",(char *)"+RTS",(char *)"-N",(char *)"-RTS"}; + int argc = 4; + char **pargv = argv; + hs_init(&argc, &pargv); + return startMachine(); +} +void kill_machine() { hs_exit(); } +void wrap_external_call( + HsStablePtr wrapped_comms, + ExtCallType ext_call_type, + BeamType beam_type, + CollimatorPosition collimator_position, + HsInt beam_energy +) { + + externalCallWrap( + wrapped_comms, + ext_call_type, + beam_type, + collimator_position, + beam_energy + ); +} diff --git a/csrc/Therac.h b/csrc/Therac.h new file mode 100644 index 0000000..05f3e1a --- /dev/null +++ b/csrc/Therac.h @@ -0,0 +1,59 @@ +#include +typedef enum ExtCallType { + CheekyPadding, + ExtCallSendMEOS, + ExtCallToggleDatentComplete, + ExtCallToggleEditingTakingPlace, + ExtCallReset, + ExtCallProceed +} ExtCallType; + +typedef enum BeamType { + BTCheekyPadding, + BeamTypeXRay, + BeamTypeElectron, + BeamTypeUndefined +} BeamType; +typedef enum CollimatorPosition { + CPCheekyPadding, + CollimatorPositionXRay, + CollimatorPositionElectronBeam, + CollimatorPositionUndefined +} CollimatorPosition; +typedef enum StateInfoRequest { + SIRCheekyPadding, + RequestTreatmentOutcome, + RequestActiveSubsystem, + RequestTreatmentState, + RequestReason, + RequestBeamMode, + RequestBeamEnergy +} StateInfoRequest; +#ifdef __cplusplus +extern "C" { // only need to export C interface if + // used by C++ source code +#endif +#if mingw32_HOST_OS || _WIN32 +__declspec(dllexport) HsStablePtr start_machine(); +__declspec(dllexport) void kill_machine(); +__declspec(dllexport) void wrap_external_call( + HsStablePtr wrapped_comms, + ExtCallType ext_call_type, + BeamType beam_type, + CollimatorPosition collimator_position, + HsInt beam_energy +); +#else +HsStablePtr start_machine(); +void kill_machine(); +void wrap_external_call( + HsStablePtr wrapped_comms, + ExtCallType ext_call_type, + BeamType beam_type, + CollimatorPosition collimator_position, + HsInt beam_energy +); +#endif +#ifdef __cplusplus +} +#endif diff --git a/hstherac25.cabal b/hstherac25.cabal index ea04a75..f5697cd 100644 --- a/hstherac25.cabal +++ b/hstherac25.cabal @@ -76,7 +76,8 @@ foreign-library hstherac25 random >= 1.2.1.1, stm other-modules: HsTherac25 - cxx-sources: cxxsrc/TheracSimulatorAdapter.cpp + c-sources: csrc/Therac.c +-- cxx-sources: cxxsrc/TheracSimulatorAdapter.cpp -- cxx-sources: cxxsrc/TheracSimulatorAdapter.hpp, cxxsrc/TheracSimulatorAdapter.cpp library -- Import common warning flags.