mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-04 18:03:41 +00:00
Fixed: Converted the tool 'objj2objcskeleton' for Node
This commit is contained in:
@@ -2,12 +2,16 @@
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
stream = require("narwhal/term").stream;
|
||||
var fs = require("fs"),
|
||||
acorn = require("objj-parser"),
|
||||
walk = require("objj-parser/util/walk"),
|
||||
stream = ObjectiveJ.term;
|
||||
|
||||
debugger;
|
||||
|
||||
function main(args)
|
||||
{
|
||||
debugger;
|
||||
args.shift();
|
||||
|
||||
if (args.length < 1)
|
||||
@@ -18,14 +22,14 @@ function main(args)
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
print("objj2objskeleton [FILE] [DESTINATION]");
|
||||
print("Convert a objective-j file to an objective-c files skeleton (.h and .m)")
|
||||
console.log("objj2objskeleton [FILE] [DESTINATION]");
|
||||
console.log("Convert a objective-j file to an objective-c files skeleton (.h and .m)")
|
||||
}
|
||||
|
||||
// Debug function to print some JS objects
|
||||
function dump(obj)
|
||||
{
|
||||
print(JSON.stringify(obj));
|
||||
console.log(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function raise(pos, message)
|
||||
@@ -37,7 +41,7 @@ function raise(pos, message)
|
||||
}
|
||||
|
||||
var errors = [],
|
||||
xcc = ObjectiveJ.acorn.walk.make(
|
||||
xcc = walk.make(
|
||||
{
|
||||
ClassDeclarationStatement: function(node, st, c)
|
||||
{
|
||||
@@ -83,7 +87,7 @@ var errors = [],
|
||||
{
|
||||
var selectors = node.selectors,
|
||||
arguments = node.arguments,
|
||||
methodReturnType = [node.returntype ? node.returntype.name : "id"],
|
||||
//methodReturnType = [node.returntype ? node.returntype.name : "id"],
|
||||
methodHasAction = node.action ? "IBAction" : null,
|
||||
selector = selectors[0].name,
|
||||
actionInfo = {"name": selector, "arguments":[]};
|
||||
@@ -149,9 +153,8 @@ function parser(args)
|
||||
baseFilenameWithNoExtension = args.shift() == "-n" ? args.shift() : baseFilename.substring(0, baseFilename.length - 2),
|
||||
outputHeaderURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".h"]),
|
||||
outputImplementationURL = new CFURL([outputDirectory stringByAppendingPathComponent:baseFilenameWithNoExtension + ".m"]),
|
||||
source = FILE.read(sourcePath, { charset: "UTF-8" }),
|
||||
flags = ObjectiveJ.Preprocessor.Flags.IncludeDebugSymbols | ObjectiveJ.Preprocessor.Flags.IncludeTypeSignatures,
|
||||
tokens = ObjectiveJ.acorn.parse(source, { locations:true, sourceFile:sourcePath }),
|
||||
source = fs.readFileSync(sourcePath, { encoding: "utf8" }),
|
||||
tokens = acorn.parse(source, { locations:true, sourceFile:sourcePath }),
|
||||
classesInformation = [],
|
||||
ObjectiveCSource = "",
|
||||
ObjectiveCHeader = "",
|
||||
@@ -186,7 +189,7 @@ function parser(args)
|
||||
});
|
||||
|
||||
if (aClass.actions.length > 0)
|
||||
ObjectiveCHeader += "\n";
|
||||
ObjectiveCHeader += "\n";
|
||||
|
||||
// add each action in header
|
||||
aClass.actions.forEach(function(anAction)
|
||||
@@ -204,10 +207,10 @@ function parser(args)
|
||||
});
|
||||
|
||||
if (ObjectiveCSource.length)
|
||||
FILE.write(outputImplementationURL, ObjectiveCSource, { charset:"UTF-8" });
|
||||
fs.writeFileSync(outputImplementationURL.absoluteString(), ObjectiveCSource, 'utf8');
|
||||
|
||||
if (ObjectiveCHeader.length)
|
||||
FILE.write(outputHeaderURL, ObjectiveCHeader, { charset:"UTF-8" });
|
||||
fs.writeFileSync(outputHeaderURL.absoluteString(), ObjectiveCHeader, 'utf8');
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
@@ -227,7 +230,7 @@ function parser(args)
|
||||
stream.printError([plist rawString]);
|
||||
|
||||
// If there were category warnings, hasErrors is NO, so return a warning status
|
||||
OS.exit(hasErrors ? 1 : 2);
|
||||
process.exit(hasErrors ? 1 : 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user