Fixed: Converted the tool 'objj2objcskeleton' for Node

This commit is contained in:
Martin Carlberg
2021-09-15 17:32:31 +02:00
parent ab4c87e69f
commit b7c04d7d16
3 changed files with 32 additions and 22 deletions
+1 -1
View File
@@ -5,4 +5,4 @@ require("../common.jake");
//subtasks(["fontinfo", "imagesize"], ["clean", "clobber"]);
subtasks(["fontinfo", "imagesize", "nib2cib", "capp"], ["build", /*"clean", "clobber"*/]);
subtasks(["fontinfo", "imagesize", "nib2cib", "objj2objcskeleton", "capp"], ["build", /*"clean", "clobber"*/]);
+13 -6
View File
@@ -1,12 +1,19 @@
require ("../../common.jake");
var FILE = require("file"),
SYSTEM = require("system");
const path = require("path");
const fs = require("fs");
const utilsFile = ObjectiveJ.utils.file;
var p = FILE.Path(path.join(SYSTEM.prefix, "bin", "objj2objcskeleton"));
const $BUILD_BIN_FILE = path.join($BUILD_CJS_CAPPUCCINO_BIN, 'objj2objcskeleton');
const $OBJJ_2_OBJC_SKELETON_FILES = new FileList("objj2objcskeleton");
filedir($BUILD_BIN_FILE, $OBJJ_2_OBJC_SKELETON_FILES, function(aTask)
{
utilsFile.cp("objj2objcskeleton", $BUILD_BIN_FILE);
fs.chmodSync($BUILD_BIN_FILE, 0o755);
});
task("build", $BUILD_BIN_FILE);
sudo(["cp", "-f", "objj2objcskeleton", p]);
sudo(["chmod", "755", p]);
+18 -15
View File
@@ -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);
}
}