new strategy
[cdsspec-compiler.git] / notes / generated_code_examples.txt
index e1eed1936eace4c99bd83304791d5f8ba7321336..506c5af7cf3cc33d2c68071e596ab87c2cad379d 100644 (file)
@@ -9,29 +9,73 @@ Global Variable Declaration
 #ifndef __SPEC_SEQUENTIAL_GENERATED_H
 #define __SPEC_SEQUENTIAL_GENERATED_H
 #include <specannotation.h>
-#include <spec_private_hashtable.h>
 #include <spec_tag.h>
 
-/* Beginning of struct Sequential */
-typedef struct Sequential {
-       spec_private_hashtable interface;
-       Tag global_call_sequence;
+/* Include all the header files that contains the interface declaration */
+#include <iostream>
+#inlcude <atomic>
+#include <memory>
+#include <assert.h>
+
+/* All other user-defined functions */
+ALL_USER_DEFINED_FUNCTIONS
 
-       /* Beginning of other user-defined variables */
-       bool lock_acquired;
-       int reader_lock_cnt;
-       /* End of other user-defined variables */
+/* Definition of interface info struct (per interface) */
+typedef struct Put_info {
+       shared_ptr<TypeV> __RET__;
+       TypeK & key;
+       TypeV & value;
+} Put_info;
+
+typedef struct Get_info {
+       shared_ptr<TypeV> __RET__;
+       TypeK & key;
+} Get_info;
+/* End of info struct definition */
+
+
+/* All function of action and check of interfaces */
+bool Put_check_action(void *info) {
+       bool check_passed;
+       Put_info *theInfo = (Put_info) info;
+       shared_ptr<TypeV> __RET__ = theInfo->__RET__;
+       TypeK & key = theInfo->key;
+       TypeV & value = theInfo->value;
+
+       // Check
+       check_passed = PUT_CHECK_EXPRESSION;
+       if (!check_passed)
+               return false;
+
+       // Action
+       PUT_ACTION
+
+       /* DefineVars */
+       TypeV *_Old_Val = DefineVarExpr;
+
+       // Post_check
+       check_passed = PUT_POST_CHECK_EXPRESSION;
+       if (!check_passed)
+               return false;
+
+       // Post_action
+       PUT_POST_ACTION
+}
 
-} Sequential; /* End of struct Sequential */
+id_t Put_id() {
+       id_t id = PUT_ID;
+       return id;
+}
+
+
+/* Beginning of other user-defined variables */
+bool lock_acquired;
+int reader_lock_cnt;
+/* End of other user-defined variables */
 
-/* Instance of the struct */
-Sequential __sequential;
 
 /* Define function for sequential code initialization */
 void __sequential_init() {
-       /* Init internal variables */
-       init(&__sequential.interface);
-       init(&global_call_sequence);
        /* Init user-defined variables */
        lock_acquired = false;
        reader_lock_cnt = 0;
@@ -49,9 +93,6 @@ void __sequential_init() {
        cdsannotate(SPEC_ANALYSIS, &hb_init0);
 }
 
-/* All other user-defined functions */
-ALL_USER_DEFINED_FUNCTIONS
-
 #endif