mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-01 18:58:22 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
commit
bdf20b0267
7 files changed
+921
-745
No files matched your search
@@ -1378,12 +1378,12 @@ var selectorCompare = function selectorCompare(object1, object2, selector)
|
||||
// sort using sort descriptors
|
||||
var compareObjectsUsingDescriptors= function compareObjectsUsingDescriptors(lhs, rhs, descriptors)
|
||||
{
|
||||
var result,
|
||||
var result = CPOrderedSame,
|
||||
i = 0,
|
||||
n = [descriptors count];
|
||||
|
||||
while (i < n && result == CPOrderedSame);
|
||||
result = [descriptors[i++] compareObject:lhs withObject:rhs];
|
||||
while (i < n && result === CPOrderedSame)
|
||||
result = [descriptors[i++] compareObject:lhs withObject:rhs];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -90,50 +90,41 @@ task ("docs", ["documentation"]);
|
||||
|
||||
task ("documentation", function()
|
||||
{
|
||||
var doxygen = null,
|
||||
DoxygenAppPath = "/Applications/Doxygen.app/Contents/Resources";
|
||||
// try to find a doxygen executable in the PATH;
|
||||
var doxygen = executableExists("doxygen");
|
||||
|
||||
// If the Doxygen application is installed on Mac OS X, use that
|
||||
if (executableExists("mdfind"))
|
||||
if (!doxygen && executableExists("mdfind"))
|
||||
{
|
||||
OS.system("mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemCFBundleIdentifier == 'org.doxygen'\" > doxygen_app");
|
||||
|
||||
if (FILE.exists("doxygen_app"))
|
||||
var p = OS.popen(["mdfind", "kMDItemContentType == 'com.apple.application-bundle' && kMDItemCFBundleIdentifier == 'org.doxygen'"]);
|
||||
if (p.wait() === 0)
|
||||
{
|
||||
doxygen = FILE.join(UTIL.trimEnd(FILE.read("doxygen_app")), "Contents/Resources/doxygen");
|
||||
FILE.remove("doxygen_app");
|
||||
var doxygenApps = p.stdout.read().split("\n");
|
||||
if (doxygenApps[0])
|
||||
doxygen = FILE.join(doxygenApps[0], "Contents/Resources/doxygen");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SYSTEM.env["PATH"].split(':').some(function(/*String*/ aPath)
|
||||
{
|
||||
var path = FILE.join(aPath, "doxygen");
|
||||
|
||||
if (FILE.exists(path))
|
||||
{
|
||||
doxygen = path;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (doxygen)
|
||||
if (doxygen && FILE.exists(doxygen))
|
||||
{
|
||||
print("Using " + doxygen + " for doxygen binary.");
|
||||
stream.print("\0green(Using " + doxygen + " for doxygen binary.\0)");
|
||||
|
||||
if (OS.system(["ruby", FILE.join("Tools", "Documentation", "make_headers")]))
|
||||
var documentationDir = FILE.join("Tools", "Documentation");
|
||||
|
||||
if (OS.system(["ruby", FILE.join(documentationDir, "make_headers")]))
|
||||
OS.exit(1); //rake abort if ($? != 0)
|
||||
|
||||
if (OS.system([doxygen, FILE.join("Tools", "Documentation", "Cappuccino.doxygen")]))
|
||||
OS.exit(1); //rake abort if ($? != 0)
|
||||
|
||||
rm_rf($DOCUMENTATION_BUILD);
|
||||
mv("debug.txt", FILE.join("Documentation", "debug.txt"));
|
||||
mv("Documentation", $DOCUMENTATION_BUILD);
|
||||
if (!OS.system([doxygen, FILE.join(documentationDir, "Cappuccino.doxygen")]))
|
||||
{
|
||||
rm_rf($DOCUMENTATION_BUILD);
|
||||
mv("debug.txt", FILE.join("Documentation", "debug.txt"));
|
||||
mv("Documentation", $DOCUMENTATION_BUILD);
|
||||
}
|
||||
|
||||
OS.system(["ruby", FILE.join(documentationDir, "cleanup_headers")]);
|
||||
}
|
||||
else
|
||||
print("doxygen not installed, skipping documentation generation.");
|
||||
stream.print("\0yellow(Doxygen not installed, skipping documentation generation.\0)");
|
||||
});
|
||||
|
||||
// Downloads
|
||||
|
||||
@@ -3,20 +3,14 @@
|
||||
@import <Foundation/CPNumber.j>
|
||||
@import <Foundation/CPSortDescriptor.j>
|
||||
|
||||
var ELEMENTS = 100,
|
||||
REPEATS = 10;
|
||||
|
||||
@implementation CPArrayPerformanceTest : OJTestCase
|
||||
|
||||
- (void)testSortUsingDescriptorsSpeed
|
||||
{
|
||||
|
||||
var ELEMENTS = 1000,
|
||||
REPEATS = 10,
|
||||
array = [];
|
||||
for (var i=0; i<ELEMENTS; i++) {
|
||||
var s = [Sortable new];
|
||||
[s setA:(i % 5)];
|
||||
[s setB:(ELEMENTS-i)];
|
||||
array.push(s);
|
||||
}
|
||||
var array = [self makeUnsorted];
|
||||
|
||||
var descriptors = [
|
||||
[CPSortDescriptor sortDescriptorWithKey:"a" ascending:NO],
|
||||
@@ -28,21 +22,64 @@
|
||||
for (var i=0; i<REPEATS; i++)
|
||||
{
|
||||
var sorted = [array sortedArrayUsingDescriptors:descriptors];
|
||||
|
||||
// Verify it really got sorted.
|
||||
for (var j=0; j<ELEMENTS; j++) {
|
||||
var expectedA = 4-FLOOR(j * 5 / ELEMENTS);
|
||||
if (sorted[j].a != expectedA)
|
||||
[self fail:"a out of order: "+expectedA+" != "+sorted[j].a];
|
||||
var expectedB = (5-expectedA) + 5 * (j % (ELEMENTS / 5))
|
||||
if (sorted[j].b != expectedB)
|
||||
[self fail:"b out of order: "+expectedB+" != "+sorted[j].b];
|
||||
}
|
||||
[self checkSorted:sorted];
|
||||
}
|
||||
|
||||
var end = (new Date).getTime();
|
||||
|
||||
CPLog.warn("testSortUsingDescriptorsSpeed: "+(end-start)+"ms");
|
||||
CPLog.warn(_cmd+": "+(end-start)+"ms");
|
||||
}
|
||||
|
||||
- (void)testSortUsingNativeSort
|
||||
{
|
||||
var array = [self makeUnsorted];
|
||||
|
||||
var descriptors = [
|
||||
[CPSortDescriptor sortDescriptorWithKey:"a" ascending:NO],
|
||||
[CPSortDescriptor sortDescriptorWithKey:"b" ascending:YES]
|
||||
];
|
||||
|
||||
function sortFunction(lhs, rhs) {
|
||||
return ([lhs a] === [rhs a]) ? ([lhs b] - [rhs b]) : ([rhs a] - [lhs a]);
|
||||
}
|
||||
|
||||
var start = (new Date).getTime();
|
||||
|
||||
for (var i=0; i<REPEATS; i++)
|
||||
{
|
||||
var sorted = [array copy];
|
||||
sorted.sort(sortFunction)
|
||||
[self checkSorted:sorted];
|
||||
}
|
||||
|
||||
var end = (new Date).getTime();
|
||||
|
||||
CPLog.warn(_cmd+": "+(end-start)+"ms");
|
||||
}
|
||||
|
||||
- (CPArray)makeUnsorted
|
||||
{
|
||||
var array = [];
|
||||
for (var i=0; i<ELEMENTS; i++) {
|
||||
var s = [Sortable new];
|
||||
[s setA:(i % 5)];
|
||||
[s setB:(ELEMENTS-i)];
|
||||
array.push(s);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
- (void)checkSorted:(CPArray)sorted
|
||||
{
|
||||
// Verify it really got sorted.
|
||||
for (var j=0; j<ELEMENTS; j++) {
|
||||
var expectedA = 4-FLOOR(j * 5 / ELEMENTS);
|
||||
if (sorted[j].a != expectedA)
|
||||
[self fail:"a out of order: "+expectedA+" != "+sorted[j].a];
|
||||
var expectedB = (5-expectedA) + 5 * (j % (ELEMENTS / 5))
|
||||
if (sorted[j].b != expectedB)
|
||||
[self fail:"b out of order: "+expectedB+" != "+sorted[j].b];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#! /usr/bin/env ruby
|
||||
|
||||
filename = File.dirname(__FILE__) + "/header_files"
|
||||
@files = File.new(filename).read.split("\n")
|
||||
|
||||
for file in @files
|
||||
File.delete(file)
|
||||
end
|
||||
|
||||
File.delete(filename)
|
||||
@@ -9,6 +9,7 @@ def makeHeaderFileFrom(fileName)
|
||||
# Extract out all the "implementation" lines. Note, there may be
|
||||
# more than on in a given .j file.
|
||||
m = data.scan(/.*?(@implementation.*?\{.*?\})/m)
|
||||
|
||||
if m.length > 0
|
||||
for i in 0...m.length
|
||||
line = m[i][0]
|
||||
@@ -18,6 +19,7 @@ def makeHeaderFileFrom(fileName)
|
||||
|
||||
# Extract the class name
|
||||
m2 = line.scan(/.*?@implementation(.*?):.*/m)
|
||||
|
||||
if !m2.nil? && !m2[0].nil?
|
||||
className = m2[0][0].strip()
|
||||
|
||||
@@ -35,12 +37,12 @@ def makeHeaderFileFrom(fileName)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
fileList = Dir['AppKit/**/*.j'] + Dir['Foundation/**/*.j']
|
||||
|
||||
for fileName in fileList
|
||||
makeHeaderFileFrom(fileName)
|
||||
end
|
||||
|
||||
for fileName in @outputFiles
|
||||
File.delete(fileName)
|
||||
end
|
||||
f = File.new(File.dirname(__FILE__) + "/header_files", "w")
|
||||
f.write(@outputFiles.join("\n"))
|
||||
f.close()
|
||||
+8
-5
@@ -266,12 +266,15 @@ global.subjake = function(/*Array<String>*/ directories, /*String*/ aTaskName)
|
||||
});
|
||||
}
|
||||
|
||||
global.executableExists = function(/*String*/ aFileName)
|
||||
global.executableExists = function(/*String*/ executableName)
|
||||
{
|
||||
return SYSTEM.env["PATH"].split(':').some(function(/*String*/ aPath)
|
||||
{
|
||||
return FILE.exists(FILE.join(aPath, aFileName));
|
||||
});
|
||||
var paths = SYSTEM.env["PATH"].split(':');
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var path = FILE.join(paths[i], executableName);
|
||||
if (FILE.exists(path))
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
$OBJJ_TEMPLATE_EXECUTABLE = FILE.join($HOME_DIR, "Objective-J", "CommonJS", "objj-executable");
|
||||
|
||||
Reference in new issue
Block a user