瀏覽代碼

Add a new "model_types" function

Yentl Van Tendeloo 8 年之前
父節點
當前提交
03f26b6159
共有 2 個文件被更改,包括 31 次插入0 次删除
  1. 23 0
      bootstrap/core_algorithm.alc
  2. 8 0
      wrappers/modelverse.py

+ 23 - 0
bootstrap/core_algorithm.alc

@@ -2018,6 +2018,27 @@ String function cmd_transformation_signature(transformation_name : String):
 			return "Model is not an operation: " + transformation_name!
 	else:
 		return "No such operation: " + transformation_name!
+
+String function cmd_model_types(model_name : String):
+	if (get_entry_id(model_name) != ""):
+		String model_id
+		model_id = get_entry_id(model_name)
+
+		Element types
+		String type
+		String result
+
+		result = "Success: "
+		types = allAssociationDestinations(core, model_id, "instanceOf")
+		while (set_len(types) > 0):
+			type = set_pop(types)
+			log("Checking type: " + cast_v2s(type))
+			log("Name attr: " + cast_v2s(read_attribute(core, type, "name")))
+			result = string_join(result, full_name(type) + "\n")
+
+		return result!
+	else:
+		return "No such model: " + model_name!
 	
 String function cmd_element_list_nice(model_name : String, metamodel_name : String):
 	if (get_entry_id(model_name) != ""):
@@ -2165,6 +2186,8 @@ Void function user_function_skip_init(user_id : String):
 		elif (cmd == "service_poll"):
 			// TODO
 			cmd = "FAIL"
+		elif (cmd == "model_types"):
+			output(cmd_model_types(single_input("Model name?")))
 		else:
 			output("Unknown command: " + cmd)
 

+ 8 - 0
wrappers/modelverse.py

@@ -1003,6 +1003,14 @@ def add_conformance(model_name, metamodel_name, partial_type_mapping=None):
     _handle_output("Success")
 
 def folder_create(folder_name):
+    """Create a new folder."""
     _goto_mode(MODE_MODELLING)
     _input(["folder_create", folder_name])
     _handle_output("Success")
+
+def model_types(model_name):
+    """Fetch all typings defined for this specific model."""
+    _goto_mode(MODE_MODELLING)
+    _input(["model_types", model_name])
+    output = _handle_output("Success: ", split=True)
+    return set(output)