Kaynağa Gözat

Update to build_for call

Billy Barrow 9 ay önce
ebeveyn
işleme
73f83641b6

+ 7 - 7
src/lib/Dependencies.vala

@@ -8,13 +8,13 @@ namespace Usm {
         public Set<ResourceRef>? acquire { get; set; }
 
         public static PropertyMapper<Dependencies> get_mapper() {
-            return once<PropertyMapper<Dependencies>>(() => new PropertyMapperBuilder<Dependencies>()
-                .map_many<string>("runtime", o => o.runtime.select<string>(i => i.to_string()), (o, v) => o.runtime = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set())
-                .map_many<string>("build", o => o.build.select<string>(i => i.to_string()), (o, v) => o.build = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set())
-                .map_many<string>("manage", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set())
-                .map_many<string>("acquire", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set(), false)
-                .set_constructor(() => new Dependencies())
-                .build());
+            return PropertyMapper.build_for<Dependencies>(cfg => {
+                cfg.map_many<string>("runtime", o => o.runtime.select<string>(i => i.to_string()), (o, v) => o.runtime = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("build", o => o.build.select<string>(i => i.to_string()), (o, v) => o.build = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("manage", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set());
+                cfg.map_many<string>("acquire", o => o.manage.select<string>(i => i.to_string()), (o, v) => o.manage = v.convert<ResourceRef>(i => new ResourceRef(i)).to_set(), false);
+                cfg.set_constructor(() => new Dependencies());
+            });
         }
     }
 }

+ 8 - 8
src/lib/Exectuables.vala

@@ -9,14 +9,14 @@ namespace Usm {
         public string? acquire { get; set; }
 
         public static PropertyMapper<Executables> get_mapper() {
-            return once<PropertyMapper<Executables>>(() => new PropertyMapperBuilder<Executables>()
-                .map<string>("build", o => o.build, (o, v) => o.build = v)
-                .map<string?>("rebuild", o => o.rebuild, (o, v) => o.rebuild = v, false)
-                .map<string?>("acquire", o => o.acquire, (o, v) => o.acquire = v, false)
-                .map<string?>("install", o => o.install, (o, v) => o.remove = v, false)
-                .map<string?>("remove", o => o.remove, (o, v) => o.remove = v, false)
-                .set_constructor(() => new Executables())
-                .build());
+            return PropertyMapper.build_for<Executables>(cfg => {
+                cfg.map<string>("build", o => o.build, (o, v) => o.build = v);
+                cfg.map<string?>("rebuild", o => o.rebuild, (o, v) => o.rebuild = v, false);
+                cfg.map<string?>("acquire", o => o.acquire, (o, v) => o.acquire = v, false);
+                cfg.map<string?>("install", o => o.install, (o, v) => o.remove = v, false);
+                cfg.map<string?>("remove", o => o.remove, (o, v) => o.remove = v, false);
+                cfg.set_constructor(() => new Executables());
+            });
         }
     }
 

+ 8 - 8
src/lib/File.vala

@@ -11,14 +11,14 @@ namespace Usm {
         public Vector<InstallType>? skip_for { get; set; }
 
         public static PropertyMapper<ManifestFile> get_mapper() {
-            return once<PropertyMapper<ManifestFile>>(() => new PropertyMapperBuilder<ManifestFile>()
-                .map<string>("path", o => o.path, (o, v) => o.path = v)
-                .map<string>("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v))
-                .map<string>("dest", o => o.destination, (o, v) => o.destination = v, false)
-                .map_many<string>("keepOn", o => o.keep_on.select<string>(i => i.to_string()), (o, v) => o.keep_on = v.convert<RemoveType>(i => RemoveType.from_string(i)).to_vector(), false)
-                .map_many<string>("skipFor", o => o.skip_for.select<string>(i => i.to_string()), (o, v) => o.skip_for = v.convert<InstallType>(i => InstallType.from_string(i)).to_vector(), false)
-                .set_constructor(() => new ManifestFile())
-                .build());
+            return PropertyMapper.build_for<ManifestFile>(cfg => {
+                cfg.map<string>("path", o => o.path, (o, v) => o.path = v);
+                cfg.map<string>("type", o => o.file_type.to_string(), (o, v) => o.file_type = ManifestFileType.from_string(v));
+                cfg.map<string>("dest", o => o.destination, (o, v) => o.destination = v, false);
+                cfg.map_many<string>("keepOn", o => o.keep_on.select<string>(i => i.to_string()), (o, v) => o.keep_on = v.convert<RemoveType>(i => RemoveType.from_string(i)).to_vector(), false);
+                cfg.map_many<string>("skipFor", o => o.skip_for.select<string>(i => i.to_string()), (o, v) => o.skip_for = v.convert<InstallType>(i => InstallType.from_string(i)).to_vector(), false);
+                cfg.set_constructor(() => new ManifestFile());
+            });
         }
 
         public ManifestFile.from_string(string str) {

+ 5 - 5
src/lib/Git.vala

@@ -6,11 +6,11 @@ namespace Usm {
         public string commit { get; set; }
 
         public static PropertyMapper<Git> get_mapper() {
-            return once<PropertyMapper<Git>>(() =>  new PropertyMapperBuilder<Git>()
-                .map<string>("origin", o => o.origin, (o, v) => o.origin = v)
-                .map<string>("commit", o => o.commit, (o, v) => o.commit = v)
-                .set_constructor(() => new Git())
-                .build());
+            return PropertyMapper.build_for<Git>(cfg => {
+                cfg.map<string>("origin", o => o.origin, (o, v) => o.origin = v);
+                cfg.map<string>("commit", o => o.commit, (o, v) => o.commit = v);
+                cfg.set_constructor(() => new Git());
+            });
         }
     }
 }

+ 6 - 6
src/lib/Licence.vala

@@ -44,12 +44,12 @@ namespace Usm {
         public string text_path { get; set; }
 
         public static PropertyMapper<Licence> get_mapper() {
-            return once<PropertyMapper<Licence>>(() =>  new PropertyMapperBuilder<Licence>()
-                .map<string>("name", o => o.name, (o, v) => o.name = v)
-                .map<string>("category", o => o.category.to_string(), (o, v) => o.category = LicenceCategory.from_string(v))
-                .map<string>("text", o => o.text_path, (o, v) => o.text_path = v)
-                .set_constructor(() => new Licence())
-                .build());
+            return PropertyMapper.build_for<Licence>(cfg => {
+                cfg.map<string>("name", o => o.name, (o, v) => o.name = v);
+                cfg.map<string>("category", o => o.category.to_string(), (o, v) => o.category = LicenceCategory.from_string(v));
+                cfg.map<string>("text", o => o.text_path, (o, v) => o.text_path = v);
+                cfg.set_constructor(() => new Licence());
+            });
         }
     }
 }

+ 17 - 17
src/lib/Manifest.vala

@@ -30,23 +30,23 @@ namespace Usm {
         public Properties? extra_properties { get; set; }
 
         public static PropertyMapper<Manifest> get_mapper() {
-            return once<PropertyMapper<Manifest>>(() =>  new PropertyMapperBuilder<Manifest>()
-                .map<string>("name", o => o.name, (o, v) => o.name = v)
-                .map<string>("version", o => o.version.to_string(), (o, v) => o.version = new Version.from_string(v))
-                .map<string>("summary", o => o.summary, (o, v) => o.summary = v)
-                .map_many_with<Licence>("licences", o => o.licences, (o, v) => o.licences = v.to_vector(), Licence.get_mapper())
-                .map<Properties>("provides", o => o.map_from_provides_dict(), (o, v) => o.build_provides_dict(v))
-                .map_with<Dependencies>("depends", o => o.dependencies, (o, v) => o.dependencies = v, Dependencies.get_mapper())
-                .map_with<Executables>("execs", o => o.executables, (o, v) => o.executables = v, Executables.get_mapper())
-                .map<string>("md", o => o.markdown_path, (o, v) => o.markdown_path = v, false)
-                .map<string>("url", o => o.url, (o, v) => o.url = v, false)
-                .map_many<string>("screenshots", o => o.screenshot_paths, (o, v) => o.screenshot_paths = v.to_vector(), false)
-                .map<string>("icon", o => o.icon_path, (o, v) => o.icon_path = v, false)
-                .map<string>("metainfo", o => o.metainfo_path, (o, v) => o.metainfo_path = v, false)
-                .map_with<Git>("git", o => o.git, (o, v) => o.git = v, Git.get_mapper(), false)
-                .map<Properties>("extras", o => o.extra_properties, (o, v) => o.extra_properties = v, false)
-                .set_constructor(() => new Manifest())
-                .build());
+            return PropertyMapper.build_for<Manifest>(cfg => {
+                cfg.map<string>("name", o => o.name, (o, v) => o.name = v);
+                cfg.map<string>("version", o => o.version.to_string(), (o, v) => o.version = new Version.from_string(v));
+                cfg.map<string>("summary", o => o.summary, (o, v) => o.summary = v);
+                cfg.map_many_with<Licence>("licences", o => o.licences, (o, v) => o.licences = v.to_vector(), Licence.get_mapper());
+                cfg.map<Properties>("provides", o => o.map_from_provides_dict(), (o, v) => o.build_provides_dict(v));
+                cfg.map_with<Dependencies>("depends", o => o.dependencies, (o, v) => o.dependencies = v, Dependencies.get_mapper());
+                cfg.map_with<Executables>("execs", o => o.executables, (o, v) => o.executables = v, Executables.get_mapper());
+                cfg.map<string>("md", o => o.markdown_path, (o, v) => o.markdown_path = v, false);
+                cfg.map<string>("url", o => o.url, (o, v) => o.url = v, false);
+                cfg.map_many<string>("screenshots", o => o.screenshot_paths, (o, v) => o.screenshot_paths = v.to_vector(), false);
+                cfg.map<string>("icon", o => o.icon_path, (o, v) => o.icon_path = v, false);
+                cfg.map<string>("metainfo", o => o.metainfo_path, (o, v) => o.metainfo_path = v, false);
+                cfg.map_with<Git>("git", o => o.git, (o, v) => o.git = v, Git.get_mapper(), false);
+                cfg.map<Properties>("extras", o => o.extra_properties, (o, v) => o.extra_properties = v, false);
+                cfg.set_constructor(() => new Manifest());
+            });
         }
 
         private void build_provides_dict(Properties obj) throws Error {