add lots of stuff
[cdsspec-compiler.git] / notes / generated_code_examples.txt
index 16580011f0406d370ca48a06cec4518a5cf397cc..0993e2f349fccff1518a2b522909cf1ffb3e2318 100644 (file)
@@ -77,7 +77,7 @@ bool Get_check_action(void *info, id_t __ID__) {
 
 /* Initialization of interface<->function_ptr table */
 #define INTERFACE_SIZE 2
-void* func_ptr_table[INTERFACE_SIZE * 2];
+void** func_ptr_table;
 
 /* Beginning of other user-defined variables */
 bool lock_acquired;
@@ -88,6 +88,11 @@ int reader_lock_cnt;
 /* Define function for sequential code initialization */
 void __sequential_init() {
        /* Init func_ptr_table */
+       func_ptr_table = (void**) malloc(sizeof(void*) * 2);
+       func_ptr_table[0] = (void*) &Put_id;
+       func_ptr_table[1] = (void*) &Put_check_action;
+       func_ptr_table[2] = (void*) &Get_id;
+       func_ptr_table[3] = (void*) &Get_check_action;
 
        /* Init user-defined variables */
        lock_acquired = false;
@@ -150,7 +155,6 @@ TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2)
        // And more (if any)
 
        // Interface ends
-       spec_annotation annotation_interface_end;
        INTERFACE_LABEL_info info = (INTERFACE_LABEL_info*) malloc(sizeof(INTERFACE_LABEL_info));
        info->__RET__ = __RET__;
        info->arg1 = arg1;
@@ -158,6 +162,7 @@ TypeReturn interfaceName(ARGType1 arg1, ARGType2 arg2)
        anno_interface_end interface_end;
        interface_end.interface_num = 0; // Interface number
        interface_end.info = info; // Info
+       spec_annotation annotation_interface_end;
        annotation_interface_end.type = INTERFACE_END;
        annotation_interface_end.annotation = &interface_end;
        cdsannotate(SPEC_ANALYSIS, &annoation_interface_end);