浏览代码

Fix some bootstrap functions to make them usable for the GUI

Yentl Van Tendeloo 8 年之前
父节点
当前提交
f1f4adf68a
共有 3 个文件被更改,包括 13 次插入7 次删除
  1. 1 1
      bootstrap/mini_modify.alc
  2. 11 5
      bootstrap/object_operations.alc
  3. 1 1
      interface/HUTN/includes/object_operations.alh

+ 1 - 1
bootstrap/mini_modify.alc

@@ -36,7 +36,7 @@ String function pretty_print(model : Element):
 				result = result + "\n"
 
 			// Defines attributes
-			attr_list = getInstantiatableAttributes(model, v_m)
+			attr_list = getInstantiatableAttributes(model, v_m, "AttributeLink")
 			attr_keys = dict_keys(attr_list)
 			while (set_len(attr_keys) > 0):
 				attr_key = set_pop(attr_keys)

+ 11 - 5
bootstrap/object_operations.alc

@@ -77,7 +77,10 @@ Element function allOutgoingAssociationInstances(model : Element, source_name :
 	i = 0
 	while (i < all_out):
 		option = reverseKeyLookup(model["model"], read_out(source, i))
-		if (is_nominal_instance(model, option, assoc_name)):
+		if (assoc_name != ""):
+			if (is_nominal_instance(model, option, assoc_name)):
+				set_add(result, option)
+		else:
 			set_add(result, option)
 		i = i + 1
 
@@ -97,7 +100,10 @@ Element function allIncomingAssociationInstances(model : Element, target_name :
 	i = 0
 	while (i < all_out):
 		option = reverseKeyLookup(model["model"], read_in(source, i))
-		if (is_nominal_instance(model, option, assoc_name)):
+		if (assoc_name != ""):
+			if (is_nominal_instance(model, option, assoc_name)):
+				set_add(result, option)
+		else:
 			set_add(result, option)
 		i = i + 1
 
@@ -130,18 +136,18 @@ Element function getAttributeList(model : Element, element : String):
 
 	return result!
 
-Element function getInstantiatableAttributes(model : Element, element : String):
+Element function getInstantiatableAttributes(model : Element, element : String, type : String):
 	Element all_links
 	Element result
 	String link
 
 	result = dict_create()
 
-	all_links = allOutgoingAssociationInstances(model, element, "Attribute")
+	all_links = allOutgoingAssociationInstances(model, element, type)
 	while (set_len(all_links) > 0):
 		link = set_pop(all_links)
 		// WARNING: do not change this to dict_add_fast, as this crashes random code...
-		dict_add(result, read_attribute(model, link, "name"), read_type(model, readAssociationDestination(model, link)))
+		dict_add(result, read_attribute(model, link, "name"), readAssociationDestination(model, link))
 
 	return result!
 

+ 1 - 1
interface/HUTN/includes/object_operations.alh

@@ -4,7 +4,7 @@ Element function selectPossibleOutgoing(model : Element, source : String, limit_
 Element function allOutgoingAssociationInstances(model: Element, source_name : String, assoc_name: String)
 Element function allIncomingAssociationInstances(model: Element, target_name : String, assoc_name: String)
 Element function getAttributeList(model: Element, element: String)
-Element function getInstantiatableAttributes(model: Element, element: String)
+Element function getInstantiatableAttributes(model: Element, element: String, type: String)
 String function print_dict(dict : Element)
 String function readAssociationSource(model : Element, name : String)
 String function readAssociationDestination(model : Element, name : String)