mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-07 17:38:02 +00:00
New: added the option --xml-output-format for the command objj
Previously, it was not possible to specify the desired output format of the command objj. Now we can have either the default format or a xml format if --xml-output-format is added.
This commit is contained in:
1 parent
65a379c8da
commit
204ed1f257
2 files changed
+59
-6
No files matched your search
@@ -94,6 +94,7 @@ exports.run = function(args)
|
||||
print(" -I, --objj-include-paths include a specific framework paths")
|
||||
print(" -h, --help print this help");
|
||||
print(" -m, --multifiles launch objj on several files")
|
||||
print(" --xml-output-format specify the output format in xml.")
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,6 +111,11 @@ exports.run = function(args)
|
||||
argv.shift();
|
||||
multipleFiles = true;
|
||||
break
|
||||
|
||||
case "--xml-output-format":
|
||||
argv.shift();
|
||||
exports.outputFormatInXML = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,6 +235,7 @@ function getPackage() {
|
||||
exports.version = function() { return getPackage()["version"]; }
|
||||
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
|
||||
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
|
||||
exports.outputFormatInXML = false;
|
||||
|
||||
exports.fullVersionString = function() {
|
||||
return sprintf("objective-j %s (%04d-%02d-%02d %s)",
|
||||
|
||||
@@ -394,9 +394,22 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*
|
||||
#ifdef BROWSER
|
||||
console.log(message);
|
||||
#else
|
||||
print(message);
|
||||
if (exports.outputFormatInXML)
|
||||
{
|
||||
var dict = new CFMutableDictionary();
|
||||
dict.addValueForKey('line', e.line);
|
||||
dict.addValueForKey('path', this.URL.absoluteString());
|
||||
dict.addValueForKey('message', message);
|
||||
|
||||
print(CFPropertyListCreateXMLData([dict], kCFPropertyListXMLFormat_v1_0).rawString());
|
||||
}
|
||||
else
|
||||
{
|
||||
print(message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -434,6 +447,8 @@ exports.ObjJAcornCompiler.compileFileDependencies = function(/*String*/ aString,
|
||||
|
||||
ObjJAcornCompiler.prototype.compilePass2 = function()
|
||||
{
|
||||
var warnings = [];
|
||||
|
||||
ObjJAcornCompiler.currentCompileFile = this.URL;
|
||||
this.pass = 2;
|
||||
this.jsBuffer = new StringBuffer();
|
||||
@@ -442,14 +457,32 @@ ObjJAcornCompiler.prototype.compilePass2 = function()
|
||||
compile(this.tokens, new Scope(null ,{ compiler: this }), pass2);
|
||||
for (var i = 0; i < this.warnings.length; i++)
|
||||
{
|
||||
var message = this.prettifyMessage(this.warnings[i], "WARNING");
|
||||
var warning = this.warnings[i],
|
||||
type = "WARNING";
|
||||
|
||||
var message = this.prettifyMessage(warning, type);
|
||||
#ifdef BROWSER
|
||||
console.log(message);
|
||||
#else
|
||||
print(message);
|
||||
if (exports.outputFormatInXML)
|
||||
{
|
||||
var dict = new CFMutableDictionary();
|
||||
dict.addValueForKey('line', warning.line)
|
||||
dict.addValueForKey('path', this.URL.absoluteString())
|
||||
dict.addValueForKey('message', message)
|
||||
|
||||
warnings.push(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
print(message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (warnings.length && exports.outputFormatInXML)
|
||||
print(CFPropertyListCreateXMLData(warnings, kCFPropertyListXMLFormat_v1_0).rawString());
|
||||
|
||||
//print(this.URL + ": " + this.jsBuffer.toString());
|
||||
return this.jsBuffer.toString();
|
||||
}
|
||||
@@ -659,10 +692,23 @@ ObjJAcornCompiler.prototype.prettifyMessage = function(/* Message */ aMessage, /
|
||||
|
||||
ObjJAcornCompiler.prototype.error_message = function(errorMessage, node)
|
||||
{
|
||||
var pos = exports.acorn.getLineInfo(this.source, node.start),
|
||||
syntaxError = {message: errorMessage, line: pos.line, column: pos.column, lineStart: pos.lineStart, lineEnd: pos.lineEnd};
|
||||
var pos = exports.acorn.getLineInfo(this.source, node.start);
|
||||
|
||||
return new SyntaxError(this.prettifyMessage(syntaxError, "ERROR"));
|
||||
if (exports.outputFormatInXML)
|
||||
{
|
||||
var dict = new CFMutableDictionary();
|
||||
dict.addValueForKey('line', pos.line);
|
||||
dict.addValueForKey('path', this.URL.absoluteString());
|
||||
dict.addValueForKey('message', errorMessage);
|
||||
|
||||
return CFPropertyListCreateXMLData([dict], kCFPropertyListXMLFormat_v1_0).rawString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var syntaxError = {message: errorMessage, line: pos.line, column: pos.column, lineStart: pos.lineStart, lineEnd: pos.lineEnd};
|
||||
|
||||
return new SyntaxError(this.prettifyMessage(syntaxError, "ERROR"));
|
||||
}
|
||||
}
|
||||
|
||||
ObjJAcornCompiler.prototype.pushImport = function(url)
|
||||
|
||||
Reference in new issue
Block a user