aboutsummaryrefslogtreecommitdiffstats
path: root/libparc/parc/algol/parc_Execution.c
diff options
context:
space:
mode:
authorLuca Muscariello <lumuscar+fdio@cisco.com>2017-02-23 17:01:02 +0100
committerLuca Muscariello <lumuscar+fdio@cisco.com>2017-02-23 17:21:02 +0100
commitec688b4723a041044226358bcd4dd6e2da39da49 (patch)
tree3a244c48d1eb9e4d90f9050fd1a61ae5c0327526 /libparc/parc/algol/parc_Execution.c
parent9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff)
Initial commit: cframework. Longbow and Libparc
Change-Id: I90378dbd30da6033b20fb1f829b3b822cf366c59 Signed-off-by: Luca Muscariello <lumuscar+fdio@cisco.com>
Diffstat (limited to 'libparc/parc/algol/parc_Execution.c')
-rw-r--r--libparc/parc/algol/parc_Execution.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/libparc/parc/algol/parc_Execution.c b/libparc/parc/algol/parc_Execution.c
new file mode 100644
index 00000000..8b31dcdb
--- /dev/null
+++ b/libparc/parc/algol/parc_Execution.c
@@ -0,0 +1,97 @@
+//
+// parc_Status.c
+// Libparc
+//
+//
+//
+#include <config.h>
+#include <stdio.h>
+
+#include "parc_Execution.h"
+
+/*
+ * A PARCExecution value is a unique thing which can have a string assigned to it.
+ *
+ * I want the function to be:
+ *
+ * A thing that returns an Execution
+ *
+ * Execution function() { }
+ *
+ * A thing that an Execution value can be
+ *
+ * Execution value = function;
+ */
+
+struct PARCExecution {
+ struct PARCExecution (*type)(char *format, ...);
+ char *message;
+};
+
+PARCExecution *PARCExecution_OK = &(PARCExecution) {
+ .message = "OK"
+};
+
+PARCExecution *PARCExecution_Timeout = &(PARCExecution) {
+ .message = "Timeout"
+};
+
+PARCExecution *PARCExecution_Interrupted = &(PARCExecution) {
+ .message = "Interrupted"
+};
+
+PARCExecution *PARCExecution_IOError = &(PARCExecution) {
+ .message = "I/O Error"
+};
+
+PARCExecution *
+parcExecution_OK(const char *format, ...)
+{
+ return PARCExecution_OK;
+}
+
+PARCExecution *
+parcExecution_Interrupted(const char *format, ...)
+{
+ return PARCExecution_Interrupted;
+}
+
+PARCExecution *
+parcExecution_IOError(const char *format, ...)
+{
+ return PARCExecution_IOError;
+}
+
+bool
+parcExecution_Is(const PARCExecution *exec, const PARCExecution *other)
+{
+ return (exec == other);
+}
+
+char *
+parcExecution_GetMessage(const PARCExecution *exec)
+{
+ return exec->message;
+}
+
+PARCExecution *
+bar()
+{
+ return PARCExecution_OK;
+}
+
+PARCExecution *
+baz()
+{
+ return parcExecution_OK("Nothing to say");
+}
+
+void
+foo()
+{
+ PARCExecution *x = bar();
+ PARCExecution *y = baz();
+
+ printf("%s\n", parcExecution_GetMessage(x));
+ printf("%s\n", parcExecution_GetMessage(y));
+}