[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] SF.net SVN: supercollider: [7395] trunk/build/SCClassLibrary/Common/Quarks



Revision: 7395
          http://svn.sourceforge.net/supercollider/?rev=7395&view=rev
Author:   cruxxial
Date:     2008-02-29 12:27:39 -0800 (Fri, 29 Feb 2008)

Log Message:
-----------
packages.sc  methods for dealing with assumed packages of classes eg. Common, crucial, jitlib, quarks ...

methods to determine what classes and methods a quark or package defines.

Quark-find

Modified Paths:
--------------
    trunk/build/SCClassLibrary/Common/Quarks/Quark.sc
    trunk/build/SCClassLibrary/Common/Quarks/Quarks.sc

Added Paths:
-----------
    trunk/build/SCClassLibrary/Common/Quarks/packages.sc

Modified: trunk/build/SCClassLibrary/Common/Quarks/Quark.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Quarks/Quark.sc	2008-02-29 20:25:43 UTC (rev 7394)
+++ trunk/build/SCClassLibrary/Common/Quarks/Quark.sc	2008-02-29 20:27:39 UTC (rev 7395)
@@ -58,6 +58,9 @@
 	*new { | blob, parent |
 		^super.new.init(blob, parent)
 	}
+	*find { |name|
+		^Quarks.local.quarks.detect({ |q| q.name == name })
+	}
 	init { | blob , argParent |
 		parent = argParent;
 
@@ -144,16 +147,8 @@
 	postDesc {
 		this.longDesc.postln;
 	}
-	== { arg that; 
-		^that respondsTo: #[name, summary, version, author, dependencies, tags, path] 
-			and: {(this.name  == that.name)
-			and: {this.summary == that.summary}
-			and: {this.version  == that.version}
-			and: {this.author  == that.author}
-			and: {this.dependencies  == that.dependencies}
-			and: {this.tags  == that.tags}
-			and: {this.path  == that.path}
-		}
+	== { arg that;
+		^this.compareObject(that,[\name, \summary, \version, \author, \dependencies, \tags, \path]);
 	}
 	dependencies { |recursive = false, knownList|
 		var deps, quark, selfasdep;

Modified: trunk/build/SCClassLibrary/Common/Quarks/Quarks.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Quarks/Quarks.sc	2008-02-29 20:25:43 UTC (rev 7394)
+++ trunk/build/SCClassLibrary/Common/Quarks/Quarks.sc	2008-02-29 20:27:39 UTC (rev 7395)
@@ -5,7 +5,7 @@
   *
   *  this is the interface class for 
   *   accessing the SVN repository, (eg. the sourceforge quarks project)
-  *   downloading those to the local quarks folder (Platform.userExtensionDir/quarks)
+  *   downloading those to the local quarks folder (Platform.userAppSupportDir/quarks)
   *   installing individual quarks by symlinking from the local quark folder into the [Platform dependent]/Extensions folder
   *
   */

Added: trunk/build/SCClassLibrary/Common/Quarks/packages.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Quarks/packages.sc	                        (rev 0)
+++ trunk/build/SCClassLibrary/Common/Quarks/packages.sc	2008-02-29 20:27:39 UTC (rev 7395)
@@ -0,0 +1,149 @@
+
++ Main {
+	// a package is either a quark or a folder in SCClassLibrary or extensions folders
+	
+	// a class is in a 'package' determined by where its Class file is
+	// all folders in class library :
+		// Common
+		// JITlib
+		// crucial
+		// your own
+	// all folders in system extension
+	// all folders in user extension
+	// all quarks
+	// any loose files are placed in a packaged calle SCClassLibrary or Extensions
+		// possiblity for error: if you have loose files in user extensions and system extensions
+		// they will both be placed in the same package: Extensions
+
+	// [ name -> folderPath, name -> folderPath ... ]
+	*packages {
+		
+		var platform,scClassLibrary,looseFiles;
+		var packages,f;
+
+		// cache
+		packages = Library.at(Quarks,\packages);
+		if(packages.notNil,{ ^packages });
+		
+		platform = thisProcess.platform;
+
+		f = { arg dir;
+			var folders,packages,paths,files;
+			dir = dir.withTrailingSlash;
+			paths = (dir++"*").pathMatch;
+			folders = paths.reject({ |p| p.last != $/ or: {PathName(p).folderName == "quarks"} });
+			files = paths.select({ |p| p.last != $/ });
+			packages = folders.collect({ |p| (PathName(p).folderName).asSymbol -> p });
+			if(files.notEmpty,{
+				// if there are any loose files then create a package called dir
+				packages = packages.add( PathName(dir).folderName.asSymbol -> dir )
+			});
+			packages
+		};
+
+		packages = 
+			(f.value(platform.classLibraryDir)
+
+			++
+
+			f.value(platform.systemExtensionDir)
+
+			++
+
+			Quarks.installed.collect({ |q|
+				q.name.asSymbol -> (platform.userExtensionDir++"/quarks/" ++ q.path)
+			}))
+			.sort({ |a,b| a.value.size > b.value.size }) // sort longer paths first
+
+			++
+
+			f.value(platform.userExtensionDir);
+		Library.put(Quarks,\packages,packages);
+		^packages
+	}
+}
+
++ Class {
+	package {
+		var path;
+		path = this.filenameSymbol.asString;
+		Main.packages.do({ |namepath|
+			if(path.copyRange(0,namepath.value.size-1) == namepath.value,{
+				^namepath.key
+			})
+		});
+		Error("Discrepancy: Package not found for class !").throw;
+	}
+}
+
+/*
+	method
+		extensions:
+			may not be the package that its class is in
+*/
++ Method {
+	package {
+		var path;
+		path = this.filenameSymbol.asString;
+		Main.packages.do({ |namepath|
+			if(path.copyRange(0,namepath.value.size-1) == namepath.value,{
+				^namepath.key
+			})
+		});
+		Error("Discrepancy: Package not found for method !").throw;
+	}
+}
+
+
++ Quark {
+
+	definesClasses {
+		var myPath,end;
+		myPath = thisProcess.platform.userExtensionDir++"/quarks/" ++ this.path;
+		end = myPath.size-1;
+		^Class.allClasses.reject(_.isMetaClass).select({ |class|
+			class.filenameSymbol.asString.copyRange(0,end) == myPath
+		})
+	}
+	definesExtensionMethods {
+		// all methods whose path is in this quark folder
+		// where the class is not in this quark
+		var myPath,end;
+		myPath = thisProcess.platform.userExtensionDir++"/quarks/" ++ this.path;
+		end = myPath.size-1;
+		^Class.allClasses.collect({ |c| c.methods }).reject(IsNil).flat
+			.select({ |method|
+				method.filenameSymbol.asString.copyRange(0,end) == myPath
+				and: {
+					method.ownerClass.filenameSymbol.asString.copyRange(0,end) != myPath
+				}
+			})
+	}
+	// of the classes you defined, what packages are the superclasses in ?
+	// of the extension methods you defined, what packages are the super classes in ?
+	/*	checkDependencies {
+		
+	}*/
+}
+
++ Quarks {
+	// the equivalent to Quark-definesClasses
+	// but works for non-quarks like Quarks.classesInPackage("JITlib")
+	*classesInPackage { |packageName|
+		var myPath,end,package;
+		package = Main.packages.detect({ |pk| pk.key == packageName });
+		if(package.isNil,{ Error("Package not found:"+packageName).throw });
+		
+		myPath = package.value;
+		end = myPath.size-1;
+		^Class.allClasses.select({ |class|
+			class.isMetaClass.not and: {
+				class.filenameSymbol.asString.copyRange(0,end) == myPath
+			}
+		})
+	}
+}
+
+
+
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.