Browse Source

First steps towards callbacks in transformation_add_*

Yentl Van Tendeloo 8 years ago
parent
commit
15f18dd5bb
3 changed files with 12 additions and 3 deletions
  1. 5 0
      bootstrap/core_algorithm.alc
  2. 1 0
      doc/wrappers.rst
  3. 6 3
      wrappers/modelverse.py

+ 5 - 0
bootstrap/core_algorithm.alc

@@ -1275,6 +1275,8 @@ String function transformation_add(user_id : String, source_models : Element, ta
 		// Write out a merged metamodel containing all these models: this is the MM for the manual operation
 		// New location is available, so write
 		merged_formalism = model_fuse(set_copy(all_formalisms))
+		//modify(merged_formalism, True)
+
 		model_create(merged_formalism, "__merged_" + operation_name, user_id, type_id, "Model")
 		merged_formalism_id = get_model_id("__merged_" + operation_name)
 
@@ -1383,6 +1385,9 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 			return "Model not found: " + name!
 
 	merged_formalism = model_fuse(to_ramify)
+	log("Start modify")
+	//modify(merged_formalism, True)
+	log("End modify")
 
 	ramified_metamodel = ramify(merged_formalism)
 	model_create(ramified_metamodel, "__RAM_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")

+ 1 - 0
doc/wrappers.rst

@@ -76,6 +76,7 @@ Functions
 .. function:: verify(model_name)
 
    Verify whether *model_name* conforms to its specified metamodel, as stored in the Modelverse.
+   Returns either "OK" if the model conforms, or a string specifying the reason for non-conformance.
 
 .. function:: model_overwrite(model_name, new_model_code=None)
 

+ 6 - 3
wrappers/modelverse.py

@@ -433,7 +433,7 @@ def transformation_between(source, target):
         return set([])
     lst = set([v for v in output.split("\n")])
 
-def transformation_add_MT(source_metamodels, target_metamodels, operation_name, code):
+def transformation_add_MT(source_metamodels, target_metamodels, operation_name, code, callback=lambda: model_exit()):
     """Create a new model transformation."""
     _goto_mode(MODE_MODELLING)
 
@@ -444,11 +444,14 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
 
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_MT"] + mv_dict_rep + [operation_name])
+    #mode = MODE_MANUAL
+    #callback()
+    #mode = MODE_MODELLING
     _handle_output("Waiting for model constructors...")
     _input(compiled)
     _handle_output("Success")
 
-def transformation_add_AL(source_metamodels, target_metamodels, operation_name, code):
+def transformation_add_AL(source_metamodels, target_metamodels, operation_name, code, callback=lambda: model_exit()):
     """Create a new action language model, which can be executed."""
     _goto_mode(MODE_MODELLING)
 
@@ -463,7 +466,7 @@ def transformation_add_AL(source_metamodels, target_metamodels, operation_name,
     _input(compiled)
     _output("Success")
 
-def transformation_add_MANUAL(source_metamodels, target_metamodels, operation_name):
+def transformation_add_MANUAL(source_metamodels, target_metamodels, operation_name, callback=lambda: model_exit()):
     """Create a new manual model operation."""
     _goto_mode(MODE_MODELLING)