Skip to content

Commit

Permalink
getting more desperate lol
Browse files Browse the repository at this point in the history
  • Loading branch information
pillowtrucker committed May 17, 2024
1 parent 118b85f commit a7a224f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
28 changes: 28 additions & 0 deletions csrc/Therac.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Therac.h"
#include "HsFFI.h"
#include <HsTherac25_stub.h>
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
);
}
59 changes: 59 additions & 0 deletions csrc/Therac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <HsFFI.h>
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
3 changes: 2 additions & 1 deletion hstherac25.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a7a224f

Please sign in to comment.