Ver Fonte

feat(resource): allow canonical resources to satisfy regular dependencies

The satisfied_by method in ResourceRef now allows canonical library types
to satisfy regular library dependencies of the same name, and canonical
library resource types to satisfy regular library resource dependencies.
This enables more flexible resource resolution while maintaining type
safety.
clanker há 1 mês atrás
pai
commit
c88b4748fa
1 ficheiros alterados com 16 adições e 1 exclusões
  1. 16 1
      src/lib/ResourceRef.vala

+ 16 - 1
src/lib/ResourceRef.vala

@@ -194,7 +194,22 @@ namespace Usm {
         }
         }
 
 
         public bool satisfied_by(ResourceRef other) {
         public bool satisfied_by(ResourceRef other) {
-            return equals(other);
+            // Direct match
+            if (equals(other)) {
+                return true;
+            }
+            
+            // canonlib can satisfy lib dependencies of the same name
+            if (resource_type == ResourceType.LIBRARY && other.resource_type == ResourceType.CANONICAL_LIBRARY) {
+                return resource == other.resource;
+            }
+            
+            // canonlibres can satisfy libres dependencies of the same name
+            if (resource_type == ResourceType.LIBRARY_RESOURCE && other.resource_type == ResourceType.CANONICAL_LIBRARY_RESOURCE) {
+                return resource == other.resource;
+            }
+            
+            return false;
         }
         }
         
         
         public bool is_satisfied() {
         public bool is_satisfied() {