3 // a package is either a quark or a folder in SCClassLibrary or extensions folders
5 // a class is in a 'package' determined by where its Class file is
6 // all folders in class library :
11 // all folders in system extension
12 // all folders in user extension
14 // any loose files are placed in a packaged calle SCClassLibrary or Extensions
15 // possiblity for error: if you have loose files in user extensions and system extensions
16 // they will both be placed in the same package: Extensions
18 // [ name -> folderPath, name -> folderPath ... ]
21 var platform,scClassLibrary,looseFiles;
25 packages = Library.at(Quarks,\packages);
26 if(packages.notNil,{ ^packages });
28 platform = thisProcess.platform;
31 var folders,packages,paths,files;
32 dir = dir.withTrailingSlash;
33 paths = (dir++"*").pathMatch;
34 folders = paths.reject({ |p| p.last != $/ or: {PathName(p).folderName == "quarks"} });
35 files = paths.select({ |p| p.last != $/ });
36 packages = folders.collect({ |p| (PathName(p).folderName).asSymbol -> p });
38 // if there are any loose files then create a package called dir
39 packages = packages.add( PathName(dir).folderName.asSymbol -> dir )
45 (f.value(platform.classLibraryDir)
49 f.value(platform.systemExtensionDir)
53 Quarks.installed.collect({ |q|
54 q.name.asSymbol -> (platform.userExtensionDir++"/quarks/" ++ q.path)
56 .sort({ |a,b| a.value.size > b.value.size }) // sort longer paths first
60 f.value(platform.userExtensionDir);
61 Library.put(Quarks,\packages,packages);
69 path = this.filenameSymbol.asString;
70 Main.packages.do({ |namepath|
71 if(path.copyRange(0,namepath.value.size-1) == namepath.value,{
75 Error("Discrepancy: Package not found for class !").throw;
82 may not be the package that its class is in
87 path = this.filenameSymbol.asString;
88 Main.packages.do({ |namepath|
89 if(path.copyRange(0,namepath.value.size-1) == namepath.value,{
93 Error("Discrepancy: Package not found for method !").throw;
102 myPath = thisProcess.platform.userExtensionDir++"/quarks/" ++ this.path;
104 ^Class.allClasses.reject(_.isMetaClass).select({ |class|
105 class.filenameSymbol.asString.copyRange(0,end) == myPath
108 definesExtensionMethods {
109 // all methods whose path is in this quark folder
110 // where the class is not in this quark
112 myPath = thisProcess.platform.userExtensionDir++"/quarks/" ++ this.path;
114 ^Class.allClasses.collect({ |c| c.methods }).reject(IsNil).flat
116 method.filenameSymbol.asString.copyRange(0,end) == myPath
118 method.ownerClass.filenameSymbol.asString.copyRange(0,end) != myPath
122 // of the classes you defined, what packages are the superclasses in ?
123 // of the extension methods you defined, what packages are the super classes in ?
124 /* checkDependencies {
130 // the equivalent to Quark-definesClasses
131 // but works for non-quarks like Quarks.classesInPackage("JITlib")
132 *classesInPackage { |packageName|
133 var myPath,end,package;
134 package = Main.packages.detect({ |pk| pk.key == packageName });
135 if(package.isNil,{ Error("Package not found:"+packageName).throw });
137 myPath = package.value;
139 ^Class.allClasses.select({ |class|
140 class.isMetaClass.not and: {
141 class.filenameSymbol.asString.copyRange(0,end) == myPath