mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-07 03:07:12 +00:00
Further spriting work.
Reviewed by me.
This commit is contained in:
+10
-16
@@ -58,27 +58,21 @@
|
||||
|
||||
- (void)bundleDidFinishLoading:(CPBundle)aBundle
|
||||
{
|
||||
var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
|
||||
index = 0,
|
||||
count = paths.length,
|
||||
bundlePath = [_bundle bundlePath];
|
||||
|
||||
var themes = [_bundle objectForInfoDictionaryKey:@"CPKeyedThemes"],
|
||||
count = themes.length;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var path = paths[count];
|
||||
|
||||
if ([path pathExtension] === "keyedtheme")
|
||||
{
|
||||
var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
|
||||
initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents]
|
||||
bundle:_bundle];
|
||||
var path = [aBundle pathForResource:themes[count]],
|
||||
unarchiver = [[_CPThemeKeyedUnarchiver alloc]
|
||||
initForReadingWithData:[CPData dataWithString:objj_files[path].contents]
|
||||
bundle:_bundle];
|
||||
|
||||
[unarchiver decodeObjectForKey:@"root"];
|
||||
[unarchiver decodeObjectForKey:@"root"];
|
||||
|
||||
[unarchiver finishDecoding];
|
||||
}
|
||||
[unarchiver finishDecoding];
|
||||
}
|
||||
|
||||
|
||||
[_loadDelegate blendDidFinishLoading:self];
|
||||
}
|
||||
|
||||
|
||||
+1
-10
@@ -53,15 +53,6 @@ filedir ($COMMONJS_PRODUCT_APPKIT, ["AppKit"], function()
|
||||
|
||||
subtasks (["Tools"], ["build"/*, "clean", "clobber"*/]);
|
||||
|
||||
$THEME_PRODUCT = FILE.join(appKitTask.buildProductPath(), "Resources", "Aristo.blend");
|
||||
ThemeFiles = new FileList("Themes/Aristo/*");
|
||||
|
||||
filedir ($THEME_PRODUCT, ThemeFiles, function()
|
||||
{
|
||||
OS.system("PATH=" + OS.enquote(FILE.join($BUILD_DIR, $CONFIGURATION, "CommonJS", "objective-j", "bin")) + ":$PATH blend -d Themes/Aristo/ThemeDescriptors.j -o " + $THEME_PRODUCT + " -R Themes/Aristo/Resources");
|
||||
// rake abort if ($? != 0)
|
||||
});
|
||||
|
||||
task ("build", ["AppKit", $COMMONJS_PRODUCT_APPKIT, $THEME_PRODUCT]);
|
||||
task ("build", ["AppKit", $COMMONJS_PRODUCT_APPKIT]);//, $THEME_PRODUCT]);
|
||||
|
||||
//CLOBBER.include($ENVIRONMENT_PRODUCT)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("../../../common.jake");
|
||||
|
||||
var blend = require("objective-j/jake/blendtask").blend;
|
||||
|
||||
|
||||
blend("Aristo.blend", function(aristoTask)
|
||||
{
|
||||
aristoTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Aristo.build", $CONFIGURATION))
|
||||
aristoTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
|
||||
|
||||
aristoTask.setThemeDescriptors(new FileList("ThemeDescriptors.j"));
|
||||
aristoTask.setPlatforms([BundleTask.Platform.Browser, BundleTask.Platform.CommonJS]);
|
||||
aristoTask.setIdentifier("com.280n.blend.Aristo");
|
||||
aristoTask.setResources(new FileList("Resources/*"));
|
||||
});
|
||||
|
||||
task ("build", ["Aristo.blend"]);
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("../../../common.jake");
|
||||
|
||||
var FILE = require("file");
|
||||
|
||||
print("???");
|
||||
$BLENDTASK = "blendtask.j";
|
||||
$COMMONJS_BLENDTASK_PRODUCT = FILE.join($COMMONJS_PRODUCT, "lib-js", "objective-j", "jake", "blendtask.j");
|
||||
|
||||
filedir($COMMONJS_BLENDTASK_PRODUCT, [$BLENDTASK], function()
|
||||
{
|
||||
cp_r($BLENDTASK, $COMMONJS_BLENDTASK_PRODUCT);
|
||||
});
|
||||
|
||||
task("build", [$COMMONJS_BLENDTASK_PRODUCT]);
|
||||
@@ -0,0 +1,225 @@
|
||||
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <BlendKit/BlendKit.j>
|
||||
|
||||
|
||||
var Jake = require("jake"),
|
||||
BundleTask = require("objective-j/jake/bundletask").BundleTask;
|
||||
|
||||
|
||||
function BlendTask(aName)
|
||||
{
|
||||
BundleTask.apply(this, arguments);
|
||||
|
||||
this._themeDescriptors = [];
|
||||
this._keyedThemes = [];
|
||||
}
|
||||
|
||||
BlendTask.__proto__ = BundleTask;
|
||||
BlendTask.prototype.__proto__ = BundleTask.prototype;
|
||||
|
||||
BlendTask.prototype.packageType = function()
|
||||
{
|
||||
return "BLND";
|
||||
}
|
||||
|
||||
BlendTask.prototype.infoPlist = function()
|
||||
{
|
||||
var infoPlist = BundleTask.prototype.infoPlist.apply(this, arguments);
|
||||
|
||||
infoPlist.setValue("CPKeyedThemes", this._keyedThemes);
|
||||
|
||||
return infoPlist;
|
||||
}
|
||||
|
||||
BlendTask.prototype.themeDescriptors = function()
|
||||
{
|
||||
return this._themeDescriptors;
|
||||
}
|
||||
|
||||
BlendTask.prototype.setThemeDescriptors = function(/*Array | FileList*/ themeDescriptors)
|
||||
{
|
||||
this._themeDescriptors = themeDescriptors;
|
||||
}
|
||||
|
||||
BlendTask.prototype.defineTasks = function()
|
||||
{
|
||||
this.defineThemeDescriptorTasks();
|
||||
|
||||
BundleTask.prototype.defineTasks.apply(this, arguments);
|
||||
}
|
||||
|
||||
BlendTask.prototype.defineSourceTasks = function()
|
||||
{
|
||||
}
|
||||
|
||||
BlendTask.prototype.defineThemeDescriptorTasks = function()
|
||||
{print("in");
|
||||
var themeDescriptors = this.themeDescriptors(),
|
||||
resourcesPath = this.resourcesPath(),
|
||||
intermediatesPath = FILE.join(this.buildIntermediatesProductPath(), "Browser" + ".platform", "Resources"),
|
||||
staticPath = this.buildProductStaticPathForPlatform("Browser"),
|
||||
keyedThemes = this._keyedThemes,
|
||||
themesTaskName = this.name() + ":themes";
|
||||
print("out");
|
||||
this.enhance(themesTaskName);
|
||||
print("uuuuhmmm");
|
||||
objj_import(themeDescriptors.toArray(), YES, function()
|
||||
{
|
||||
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
|
||||
{
|
||||
var keyedThemePath = FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme");
|
||||
|
||||
filedir (keyedThemePath, themesTaskName);
|
||||
filedir (staticPath, [keyedThemePath]);
|
||||
|
||||
keyedThemes.push([aClass themeName] + ".keyedtheme");
|
||||
});
|
||||
});
|
||||
print("WHAT");
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
print("IS WRONG");
|
||||
task (themesTaskName, function()
|
||||
{print("wtf");
|
||||
[BKThemeDescriptor allThemeDescriptorClasses].forEach(function(aClass)
|
||||
{
|
||||
var themeTemplate = [[BKThemeTemplate alloc] init];
|
||||
|
||||
[themeTemplate setValue:[aClass themeName] forKey:@"name"];
|
||||
|
||||
var objectTemplates = [aClass themedObjectTemplates],
|
||||
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
|
||||
fileContents = themeFromCibData(data);
|
||||
print("will write to" + FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme"));
|
||||
FILE.write(FILE.join(intermediatesPath, [aClass themeName] + ".keyedtheme"), MARKER_TEXT + ";" + fileContents.length + ";" + fileContents, { charset:"UTF-8" });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function cibDataFromTopLevelObjects(objects)
|
||||
{
|
||||
var data = [CPData data],
|
||||
archiver = [[CPKeyedArchiver alloc] initForWritingWithMutableData:data],
|
||||
objectData = [[_CPCibObjectData alloc] init];
|
||||
|
||||
objectData._fileOwner = [_CPCibCustomObject new];
|
||||
objectData._fileOwner._className = @"CPObject";
|
||||
|
||||
var index = 0,
|
||||
count = objects.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
objectData._objectsValues[index] = objectData._fileOwner;
|
||||
objectData._objectsKeys[index] = objects[index];
|
||||
}
|
||||
|
||||
[archiver encodeObject:objectData forKey:@"CPCibObjectDataKey"];
|
||||
|
||||
[archiver finishEncoding];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function themeFromCibData(data)
|
||||
{
|
||||
var cib = [[CPCib alloc] initWithData:data],
|
||||
topLevelObjects = [];
|
||||
|
||||
[cib _setAwakenCustomResources:NO];
|
||||
[cib instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObject:topLevelObjects forKey:CPCibTopLevelObjects]];
|
||||
|
||||
var count = topLevelObjects.length,
|
||||
theme = nil,
|
||||
templates = [];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var object = topLevelObjects[count];
|
||||
|
||||
templates = templates.concat([object blendThemeObjectTemplates]);
|
||||
|
||||
if ([object isKindOfClass:[BKThemeTemplate class]])
|
||||
theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]];
|
||||
}
|
||||
|
||||
print("Building " + [theme name] + " theme");
|
||||
|
||||
[templates makeObjectsPerformSelector:@selector(blendAddThemedObjectAttributesToTheme:) withObject:theme];
|
||||
|
||||
return [[CPKeyedArchiver archivedDataWithRootObject:theme] string];
|
||||
}
|
||||
|
||||
@implementation CPCib (BlendAdditions)
|
||||
|
||||
- (id)initWithData:(CPData)aData
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
_data = aData;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPObject (BlendAdditions)
|
||||
|
||||
- (CPArray)blendThemeObjectTemplates
|
||||
{
|
||||
var theClass = [self class];
|
||||
|
||||
if ([theClass isKindOfClass:[BKThemedObjectTemplate class]])
|
||||
return [self];
|
||||
|
||||
if ([theClass isKindOfClass:[CPView class]])
|
||||
{
|
||||
var templates = [],
|
||||
subviews = [self subviews],
|
||||
count = [subviews count];
|
||||
|
||||
while (count--)
|
||||
templates = templates.concat([subviews[count] blendThemeObjectTemplates]);
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BKThemedObjectTemplate (BlendAdditions)
|
||||
|
||||
- (void)blendAddThemedObjectAttributesToTheme:(CPTheme)aTheme
|
||||
{
|
||||
var themedObject = [self valueForKey:@"themedObject"];
|
||||
|
||||
if (!themedObject)
|
||||
{
|
||||
var subviews = [self subviews];
|
||||
|
||||
if ([subviews count] > 0)
|
||||
themedObject = subviews[0];
|
||||
}
|
||||
|
||||
if (themedObject)
|
||||
{
|
||||
print(" Recording themed properties for " + [themedObject className] + ".");
|
||||
|
||||
[aTheme takeThemeFromObject:themedObject];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
exports.BlendTask = BlendTask;
|
||||
|
||||
exports.blend = function(aName, aFunction)
|
||||
{
|
||||
// No .apply necessary because the parameters aren't variable.
|
||||
return BlendTask.defineTask(aName, aFunction);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env ruby
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("../../common.jake");
|
||||
|
||||
|
||||
subtasks(["BlendKit", "blend"], ["build"/*, "clean", "clobber"*/]);
|
||||
print("WHAT");
|
||||
subtasks(["BlendKit", "CommonJS"], ["build"/*, "clean", "clobber"*/]);
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("../../../common.jake");
|
||||
|
||||
|
||||
app ("blend", function(blendTask)
|
||||
{
|
||||
blendTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "blend.build", $CONFIGURATION));
|
||||
blendTask.setBuildPath($COMMONJS_PRODUCT_LIB);
|
||||
|
||||
blendTask.setAuthor("280 North, Inc.");
|
||||
blendTask.setEmail("feedback @nospam@ 280north.com");
|
||||
blendTask.setSummary("blend classes for Cappuccino");
|
||||
blendTask.setIdentifier("blend");
|
||||
blendTask.setVersion("0.7.1");
|
||||
blendTask.setSources(new FileList("**/*.j"));
|
||||
blendTask.setResources(new FileList("Resources/**/*"));
|
||||
blendTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
blendTask.setFlattensSources(true);
|
||||
|
||||
if ($CONFIGURATION === "Release")
|
||||
blendTask.setCompilerFlags("-O");
|
||||
else
|
||||
blendTask.setCompilerFlags("-DDEBUG -g");
|
||||
});
|
||||
|
||||
$COMMONJS_BLEND_BIN_PRODUCT = FILE.join($COMMONJS_PRODUCT_BIN, "blend");
|
||||
|
||||
// executable in environment directory
|
||||
filedir($COMMONJS_BLEND_BIN_PRODUCT, ["blend"], function()
|
||||
{
|
||||
make_objj_executable($COMMONJS_BLEND_BIN_PRODUCT);
|
||||
});
|
||||
|
||||
task ("build", ["blend", $COMMONJS_BLEND_BIN_PRODUCT]);
|
||||
|
||||
/*
|
||||
CLOBBER.include($ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT)
|
||||
*/
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rake'
|
||||
require '../../../common'
|
||||
require 'objective-j'
|
||||
require 'objective-j/bundletask'
|
||||
|
||||
|
||||
$PRODUCT = :blend
|
||||
$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'blend')
|
||||
$ENVIRONMENT_BIN_PRODUCT = File.join($ENVIRONMENT_BIN_DIR, 'blend')
|
||||
$ENVIRONMENT_LIB_PRODUCT = File.join($ENVIRONMENT_LIB_DIR, 'blend')
|
||||
|
||||
# Debug Framework
|
||||
ObjectiveJ::BundleTask.new(:blend) do |t|
|
||||
t.name = 'blend'
|
||||
t.identifier = 'com.280n.blend'
|
||||
t.version = '0.7.1'
|
||||
t.author = '280 North, Inc.'
|
||||
t.email = 'feedback @nospam@ 280north.com'
|
||||
t.summary = 'blend classes for Cappuccino'
|
||||
t.sources = FileList['**/*.j']
|
||||
t.resources = FileList['Resources/*']
|
||||
t.license = ObjectiveJ::License::LGPL_v2_1
|
||||
t.build_path = $BUILD_PATH
|
||||
t.flag = '-DDEBUG' if $CONFIGURATION == 'Debug'
|
||||
t.flag = '-O' if $CONFIGURATION == 'Debug'
|
||||
end
|
||||
|
||||
#executable in environment directory
|
||||
file_d $ENVIRONMENT_BIN_PRODUCT do
|
||||
make_objj_executable($ENVIRONMENT_BIN_PRODUCT)
|
||||
end
|
||||
|
||||
file_d $ENVIRONMENT_LIB_PRODUCT => [:blend] do
|
||||
cp_r(File.join($BUILD_PATH, '.'), $ENVIRONMENT_LIB_PRODUCT)
|
||||
end
|
||||
|
||||
task :build => [:blend, $ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT]
|
||||
|
||||
CLOBBER.include($ENVIRONMENT_BIN_PRODUCT, $ENVIRONMENT_LIB_PRODUCT)
|
||||
@@ -1,311 +0,0 @@
|
||||
/*
|
||||
* main.j
|
||||
* blend
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2009, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/AppKit.j>
|
||||
@import <BlendKit/BlendKit.j>
|
||||
|
||||
var File = require("file");
|
||||
|
||||
|
||||
function main()
|
||||
{
|
||||
var index = 0,
|
||||
count = system.args.length,
|
||||
|
||||
outputFilePath = "",
|
||||
descriptorFiles = [],
|
||||
resourcesPath = nil,
|
||||
cibFiles = [],
|
||||
blendName = "Untitled";
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = system.args[index];
|
||||
|
||||
switch (argument)
|
||||
{
|
||||
case "-c":
|
||||
case "--cib": cibFiles.push(system.args[++index]);
|
||||
break;
|
||||
|
||||
case "-d":
|
||||
case "-descriptor": descriptorFiles.push(system.args[++index]);
|
||||
break;
|
||||
|
||||
case "-o": outputFilePath = system.args[++index];
|
||||
break;
|
||||
|
||||
case "-R": resourcesPath = system.args[++index];
|
||||
break;
|
||||
|
||||
default: jExtensionIndex = argument.indexOf(".j");
|
||||
|
||||
if ((jExtensionIndex > 0) && (jExtensionIndex === argument.length - ".j".length))
|
||||
descriptorFiles.push(argument);
|
||||
else
|
||||
cibFiles.push(argument);
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptorFiles.length === 0)
|
||||
return buildBlendFromCibFiles(cibFiles);
|
||||
|
||||
objj_import(descriptorFiles, YES, function()
|
||||
{
|
||||
var themeDescriptorClasses = [BKThemeDescriptor allThemeDescriptorClasses],
|
||||
count = [themeDescriptorClasses count];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var theClass = themeDescriptorClasses[count],
|
||||
themeTemplate = [[BKThemeTemplate alloc] init];
|
||||
|
||||
[themeTemplate setValue:[theClass themeName] forKey:@"name"];
|
||||
|
||||
var objectTemplates = [theClass themedObjectTemplates],
|
||||
data = cibDataFromTopLevelObjects(objectTemplates.concat([themeTemplate])),
|
||||
temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"),
|
||||
temporaryCibFilePath = String(temporaryCibFile.getAbsolutePath());
|
||||
|
||||
File.write(temporaryCibFilePath, [data string], { charset:"UTF-8" });
|
||||
|
||||
cibFiles.push(temporaryCibFilePath);
|
||||
}
|
||||
|
||||
buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath);
|
||||
});
|
||||
}
|
||||
|
||||
function cibDataFromTopLevelObjects(objects)
|
||||
{
|
||||
var data = [CPData data],
|
||||
archiver = [[CPKeyedArchiver alloc] initForWritingWithMutableData:data],
|
||||
objectData = [[_CPCibObjectData alloc] init];
|
||||
|
||||
objectData._fileOwner = [_CPCibCustomObject new];
|
||||
objectData._fileOwner._className = @"CPObject";
|
||||
|
||||
var index = 0,
|
||||
count = objects.length;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
objectData._objectsValues[index] = objectData._fileOwner;
|
||||
objectData._objectsKeys[index] = objects[index];
|
||||
}
|
||||
|
||||
[archiver encodeObject:objectData forKey:@"CPCibObjectDataKey"];
|
||||
|
||||
[archiver finishEncoding];
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function getDirectory(aPath)
|
||||
{
|
||||
return (aPath).substr(0, (aPath).lastIndexOf('/') + 1)
|
||||
}
|
||||
|
||||
function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
|
||||
{
|
||||
var resourcesFile = nil;
|
||||
|
||||
if (resourcesPath)
|
||||
resourcesFile = new Packages.java.io.File(resourcesPath);
|
||||
|
||||
var count = cibFiles.length,
|
||||
replacedFiles = [],
|
||||
staticContent = @"";
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var theme = themeFromCibFile(new Packages.java.io.File(cibFiles[count])),
|
||||
|
||||
// Archive our theme.
|
||||
filePath = [theme name] + ".keyedtheme",
|
||||
fileContents = [[CPKeyedArchiver archivedDataWithRootObject:theme] string];
|
||||
|
||||
replacedFiles.push(filePath);
|
||||
|
||||
staticContent += MARKER_PATH + ';' + filePath.length + ';' + filePath + MARKER_TEXT + ';' + fileContents.length + ';' + fileContents;
|
||||
}
|
||||
|
||||
staticContent = "@STATIC;1.0;" + staticContent;
|
||||
|
||||
var blendName = File.basename(outputFilePath),
|
||||
extension = File.extname(outputFilePath);
|
||||
|
||||
if (extension.length)
|
||||
blendName = blendName.substr(0, blendName.length - extension.length);
|
||||
|
||||
var infoDictionary = [CPDictionary dictionary],
|
||||
staticContentName = blendName + ".sj";
|
||||
|
||||
[infoDictionary setObject:blendName forKey:@"CPBundleName"];
|
||||
[infoDictionary setObject:blendName forKey:@"CPBundleIdentifier"];
|
||||
[infoDictionary setObject:replacedFiles forKey:@"CPBundleReplacedFiles"];
|
||||
[infoDictionary setObject:staticContentName forKey:@"CPBundleExecutable"];
|
||||
|
||||
var outputFile = new Packages.java.io.File(outputFilePath).getCanonicalFile();
|
||||
|
||||
outputFile.mkdirs();
|
||||
|
||||
File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF-8" });
|
||||
File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF-8" });
|
||||
|
||||
if (resourcesPath)
|
||||
rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath));
|
||||
}
|
||||
|
||||
function themeFromCibFile(aFile)
|
||||
{
|
||||
var cib = [[CPCib alloc] initWithContentsOfURL:aFile.getCanonicalPath()],
|
||||
topLevelObjects = [];
|
||||
|
||||
[cib _setAwakenCustomResources:NO];
|
||||
[cib instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObject:topLevelObjects forKey:CPCibTopLevelObjects]];
|
||||
|
||||
var count = topLevelObjects.length,
|
||||
theme = nil,
|
||||
templates = [];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var object = topLevelObjects[count];
|
||||
|
||||
templates = templates.concat([object blendThemeObjectTemplates]);
|
||||
|
||||
if ([object isKindOfClass:[BKThemeTemplate class]])
|
||||
theme = [[CPTheme alloc] initWithName:[object valueForKey:@"name"]];
|
||||
}
|
||||
|
||||
print("Building " + [theme name] + " theme");
|
||||
|
||||
[templates makeObjectsPerformSelector:@selector(blendAddThemedObjectAttributesToTheme:) withObject:theme];
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
function rsync(srcFile, dstFile)
|
||||
{
|
||||
var src, dst;
|
||||
|
||||
if (String(java.lang.System.getenv("OS")).indexOf("Windows") < 0)
|
||||
{
|
||||
src = srcFile.getAbsolutePath();
|
||||
dst = dstFile.getAbsolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
src = exec(["cygpath", "-u", srcFile.getAbsolutePath() + '/']);
|
||||
dst = exec(["cygpath", "-u", dstFile.getAbsolutePath() + "/Resources"]);
|
||||
}
|
||||
|
||||
if (srcFile.exists())
|
||||
exec(["rsync", "-avz", src, dst]);
|
||||
}
|
||||
|
||||
function exec(/*Array*/ command, /*Boolean*/ showOutput)
|
||||
{
|
||||
var line = "",
|
||||
output = "",
|
||||
|
||||
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
{
|
||||
if (showOutput)
|
||||
System.out.println(line);
|
||||
|
||||
output += line + '\n';
|
||||
}
|
||||
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
System.out.println(line);
|
||||
|
||||
try
|
||||
{
|
||||
if (process.waitFor() != 0)
|
||||
System.err.println("exit value = " + process.exitValue());
|
||||
}
|
||||
catch (anException)
|
||||
{
|
||||
System.err.println(anException);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@implementation CPObject (BlendAdditions)
|
||||
|
||||
- (CPArray)blendThemeObjectTemplates
|
||||
{
|
||||
var theClass = [self class];
|
||||
|
||||
if ([theClass isKindOfClass:[BKThemedObjectTemplate class]])
|
||||
return [self];
|
||||
|
||||
if ([theClass isKindOfClass:[CPView class]])
|
||||
{
|
||||
var templates = [],
|
||||
subviews = [self subviews],
|
||||
count = [subviews count];
|
||||
|
||||
while (count--)
|
||||
templates = templates.concat([subviews[count] blendThemeObjectTemplates]);
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation BKThemedObjectTemplate (BlendAdditions)
|
||||
|
||||
- (void)blendAddThemedObjectAttributesToTheme:(CPTheme)aTheme
|
||||
{
|
||||
var themedObject = [self valueForKey:@"themedObject"];
|
||||
|
||||
if (!themedObject)
|
||||
{
|
||||
var subviews = [self subviews];
|
||||
|
||||
if ([subviews count] > 0)
|
||||
themedObject = subviews[0];
|
||||
}
|
||||
|
||||
if (themedObject)
|
||||
{
|
||||
print(" Recording themed properties for " + [themedObject className] + ".");
|
||||
|
||||
[aTheme takeThemeFromObject:themedObject];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -152,8 +152,9 @@ var objj_preprocess_sync = function(code, path)
|
||||
return preprocessed.join("\n");
|
||||
}
|
||||
|
||||
// FIXME: Why does this need to be global?
|
||||
// synchronously perform an import
|
||||
var objj_import_sync = function(pathOrPaths, isLocal)
|
||||
global.objj_import_sync = function(pathOrPaths, isLocal)
|
||||
{
|
||||
var context = new objj_context();
|
||||
context.pushFragment(fragment_create_file(pathOrPaths, new objj_bundle(), isLocal, NULL));
|
||||
@@ -168,12 +169,14 @@ var objj_import_sync = function(pathOrPaths, isLocal)
|
||||
exports.make_narwhal_factory = function(code, path) {
|
||||
var OBJJ_CURRENT_BUNDLE = new objj_bundle();
|
||||
|
||||
var factoryText = "(function(require,exports,module,system,print){" + objj_preprocess_sync(code, path) + "/**/\n})";
|
||||
|
||||
var factoryText = "function(require,exports,module,system,print){" + objj_preprocess_sync(code, path) + "/**/\n}";
|
||||
|
||||
if (system.engine === "rhino")
|
||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, factoryText, path, 0, null);
|
||||
|
||||
// eval requires parenthesis, but parenthesis break compileFunction.
|
||||
else
|
||||
return eval(factoryText);
|
||||
return eval("(" + factoryText + ")");
|
||||
}
|
||||
|
||||
} // end "with"
|
||||
|
||||
@@ -502,11 +502,17 @@ BundleTask.prototype.defineStaticTask = function()
|
||||
{
|
||||
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
|
||||
|
||||
fileStream.write("u;" + resourcePath.length + ";" + resourcePath);
|
||||
if (IMAGE_EXTENSIONS.indexOf(FILE.extname(aFilename)) !== -1)
|
||||
fileStream.write("u;");
|
||||
else
|
||||
fileStream.write("p;");
|
||||
|
||||
fileStream.write(resourcePath.length + ";" + resourcePath);
|
||||
}
|
||||
|
||||
// FIXME: We need to do this for now due to file.read adding newlines. Revert when fixed.
|
||||
fileStream.write(FILE.read(aFilename, { charset:"UTF-8" }));
|
||||
//fileStream.write(FILE.read(aFilename, { charset:"UTF-8" }));
|
||||
fileStream.write(FILE.read(aFilename, { mode:"b" }).decodeToString("UTF-8"));
|
||||
}, this);
|
||||
|
||||
fileStream.close();
|
||||
|
||||
@@ -5,7 +5,7 @@ function ObjectiveJLoader() {
|
||||
var factories = {};
|
||||
|
||||
loader.reload = function(topId, path) {
|
||||
if (!objj) objj = require("objj/objj");
|
||||
if (!objj) objj = require("objective-j");
|
||||
|
||||
//print("loading objective-j: " + topId + " (" + path + ")");
|
||||
factories[topId] = objj.make_narwhal_factory(system.fs.read(path), path);
|
||||
|
||||
@@ -105,8 +105,8 @@ function objj_printf(string)
|
||||
objj_fprintf(alert, string);
|
||||
}
|
||||
|
||||
#if RHINO
|
||||
var warning_stream = function (aString) { Packages.java.lang.System.out.println(aString) };
|
||||
#if COMMON_JS
|
||||
var warning_stream = function (aString) { print(aString) };
|
||||
#else
|
||||
if (window.console && window.console.warn)
|
||||
var warning_stream = function(aString) { window.console.warn(aString); }
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
@import <Foundation/CPData.j>
|
||||
|
||||
var File = require("file"),
|
||||
FILE = require("file"),
|
||||
popen = require("os").popen;
|
||||
|
||||
|
||||
@@ -98,13 +99,13 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
- (CPData)CPCompliantNibDataAtFilePath:(CPString)aFilePath
|
||||
{
|
||||
// Compile xib or nib to make sure we have a non-new format nib.
|
||||
var temporaryNibFilePath = File.createTempFile("temp", ".nib", true);
|
||||
var temporaryNibFilePath = FILE.join("/tmp", aFilePath + ".tmp.nib");
|
||||
|
||||
if (popen("/usr/bin/ibtool " + aFilePath + " --compile " + temporaryNibFilePath).wait() === 1)
|
||||
throw "Could not compile file at " + aFilePath;
|
||||
|
||||
// Convert from binary plist to XML plist
|
||||
var temporaryPlistFilePath = File.createTempFile("temp", ".plist", true);
|
||||
var temporaryPlistFilePath = FILE.join("/tmp", aFilePath + ".tmp.plist");
|
||||
|
||||
if (popen("/usr/bin/plutil " + " -convert xml1 " + temporaryNibFilePath + " -o " + temporaryPlistFilePath).wait() === 1)
|
||||
throw "Could not convert to xml plist for file at " + aFilePath;
|
||||
@@ -124,17 +125,6 @@ ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
@end
|
||||
|
||||
File.createTempFile = function(aName, anExtension, shouldDeleteOnExit)
|
||||
{
|
||||
var tempFile = Packages.java.io.File.createTempFile(aName, anExtension),
|
||||
tempFilePath = String(tempFile.getAbsolutePath());
|
||||
|
||||
if (shouldDeleteOnExit)
|
||||
tempFile.deleteOnExit();
|
||||
|
||||
return String(tempFilePath);
|
||||
}
|
||||
|
||||
function cibExtension(aPath)
|
||||
{
|
||||
var start = aPath.length - 1;
|
||||
|
||||
Reference in New Issue
Block a user