Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GPSEE mostly working

  • Loading branch information...
commit b44de778abdadbe9205639e16b4753c74d65d611 1 parent a5781c2
@cadorn cadorn authored
View
3  .gitignore
@@ -3,4 +3,5 @@
.pinf-*
*.local.*
/.build/
-/node_modules/
+/node_modules/
+.*.jsc
View
22 demos/GPSEE/README.md
@@ -32,9 +32,29 @@ OSX 10.7:
make build
sudo make install
-
Make sure GPSEE is available and working:
gsr -h
gsr -f ./scripts/helloworld.js
./scripts/helloworld
+
+Usage
+=====
+
+ gsr -f ../../pinf-loader.js -- -v ../HelloWorld
+
+If the above does not work, ensure it works with nodejs first:
+
+ node ../../pinf-loader.js ../HelloWorld
+
+
+Development
+===========
+
+Updating GPSEE:
+
+ cd ./gpsee
+ hg pull
+ hg update
+ make build
+ sudo make install
View
6 demos/GPSEE/scripts/dev-gffi.js
@@ -0,0 +1,6 @@
+var ffi = require('gffi');
+['S_IFREG','S_IFDIR','O_RDONLY'].forEach(function(mac){
+ ['std','gpsee'].forEach(function(group){
+ print(group+'.'+mac+' = '+ffi[group][mac])
+ })
+});
View
117 lib/pinf-loader-js/adapter/gpsee.js
@@ -0,0 +1,117 @@
+// Authors:
+// - cadorn, Christoph Dorn <christoph@christophdorn.com>, Copyright 2011, MIT License
+
+// @see http://ringojs.org/api/v0.8/
+
+var API;
+
+var SYSTEM = require("system"),
+ FS_BASE = require("fs-base");
+
+exports.init = function(api)
+{
+ API = api;
+
+ api.ENV.platform = "gpsee";
+
+ var platformModules = {};
+
+ api.ENV.platformRequire = function(id)
+ {
+ throw new Error("ENV.platformRequire not implemented!");
+ };
+
+ api.ENV.verifyNativeModuleIdentifier = function(pkg, moduleIdentifier, args)
+ {
+ throw new Error("ENV.verifyNativeModuleIdentifier not implemented!");
+ }
+
+ // TODO: Get OS name
+ api.SYSTEM.os = "NYI-OS";
+
+ api.SYSTEM.pwd = "/pinf/workspaces/github.com/pinf/loader-js/demos/GPSEE"; //FS_BASE.workingDirectory();
+
+ api.ENV.loaderRoot = API.FILE.dirname(API.FILE.dirname(API.FILE.dirname(API.FILE.dirname(module.id))));
+
+ api.SYSTEM.env = SYSTEM.env;
+
+ if (typeof api.SYSTEM.print == "undefined")
+ {
+ api.SYSTEM.print = api.SYSTEM.plainPrint(function(msg)
+ {
+ print(msg);
+// print((""+msg).replace(/\n$/, ""));
+ });
+ }
+
+ api.SYSTEM.formatErrorStack = function(e)
+ {
+ return e.stack;
+ }
+
+ api.SYSTEM.parseArgs(SYSTEM.args);
+
+ api.SYSTEM.exec = null;
+
+/*
+ api.UTIL.setTimeout = function(callback, timeout)
+ {
+ callback();
+ };
+*/
+
+ api.UTIL.eval = function(code, scope, file, line)
+ {
+ with(scope)
+ {
+ eval(code);
+ }
+ };
+
+ /*
+ api.FILE.normalizePath = function(path)
+ {
+ return path;
+ }
+ */
+
+ api.FILE.exists = function(filename)
+ {
+ return FS_BASE.exists(filename);
+ }
+
+ api.FILE.isFile = function(filename)
+ {
+ return FS_BASE.isFile(filename);
+ }
+
+ api.FILE.read = function(filename, encoding)
+ {
+ return ""+FS_BASE.openRaw(filename, {
+ read: true
+ }).read();
+ }
+
+ api.FILE.mkdirs = function(filename)
+ {
+ throw new Error("NYI - FILE.mkdirs");
+ }
+
+ api.FILE.write = function(filename, data, encoding)
+ {
+ throw new Error("NYI - FILE.write");
+ }
+ api.FILE.rename = function(from, to)
+ {
+ throw new Error("NYI - FILE.rename");
+ }
+
+ api.NET.download = function(url, path, callback)
+ {
+ throw new Error("NYI - NET.download");
+ }
+
+ api.JSON.parse = JSON.parse;
+ api.JSON.stringify = JSON.stringify;
+}
+
View
2  lib/pinf-loader-js/adapter/ringo.js
@@ -56,8 +56,6 @@ exports.init = function(api)
api.SYSTEM.exec = null;
- var sandbox;
-
api.UTIL.setTimeout = SCHEDULER.setTimeout;
api.UTIL.eval = function(code, scope, file, line)
View
24 lib/pinf-loader-js/bravojs/plugins/packages/packages.js
@@ -31,8 +31,9 @@ Plugin.prototype.init = function()
id = id.replace(/^\w*!/, "");
- var parts = id.split("@/"),
- id = parts[0];
+ var parts = id.split("@/");
+
+ id = parts[0];
if (/@$/.test(id))
id = id.substring(0, id.length-1);
@@ -215,7 +216,7 @@ Plugin.prototype.init = function()
Plugin.prototype.requireModule = function(id)
{
if (!id)
- return;
+ return false;
// The text plugins need special handeling
if (id.match(/^text!/))
@@ -229,6 +230,7 @@ Plugin.prototype.requireModule = function(id)
}
return true;
}
+ return false;
}
Plugin.prototype.newRequire = function(helpers)
@@ -252,7 +254,7 @@ Plugin.prototype.newRequire = function(helpers)
{
callback(newRequire(id));
});
- return;
+ return false;
}
if (helpers.deps && helpers.deps[moduleIdentifier])
return helpers.deps[moduleIdentifier]();
@@ -411,9 +413,9 @@ Plugin.prototype.normalizeLocator = function(locator, context)
locator.location = locator.location.substring(0, locator.location.length -1);
if (typeof locator.location != "undefined") {
- var context = this.bravojs.contextForId(locator.location);
- if(context && context.uid) {
- locator.uid = context.uid;
+ var newContext = this.bravojs.contextForId(locator.location);
+ if(newContext && newContext.uid) {
+ locator.uid = newContext.uid;
}
}
@@ -494,11 +496,11 @@ Plugin.prototype.normalizeModuleIdentifier = function(moduleIdentifier, relative
if (typeof moduleIdentifier.descriptor != "undefined" && typeof moduleIdentifier.descriptor.main != "undefined")
return finalNormalization(this.bravojs.realpath(id + "@/" + moduleIdentifier.descriptor.main, false));
- var context = this.bravojs.contextForId(id);
- if (typeof context.descriptor == "undefined" || typeof context.descriptor.main == "undefined")
- throw new Error("'main' property not set in package descriptor for: " + context.id);
+ var newContext = this.bravojs.contextForId(id);
+ if (typeof newContext.descriptor == "undefined" || typeof newContext.descriptor.main == "undefined")
+ throw new Error("'main' property not set in package descriptor for: " + newContext.id);
- return finalNormalization(this.bravojs.realpath(context.id + "@/" + context.descriptor.main, false));
+ return finalNormalization(this.bravojs.realpath(newContext.id + "@/" + newContext.descriptor.main, false));
}
// See if moduleIdentifier matches a mapping alias exactly
View
51 lib/pinf-loader-js/downloader.js
@@ -33,10 +33,10 @@ Downloader.prototype.pathForURL = function(url, type)
if (!directoriesVerified)
{
directoriesVerified = true;
- FILE.mkdirs(this.basePath + "/downloads/files", 0775);
- FILE.mkdirs(this.basePath + "/downloads/packages", 0775);
- FILE.mkdirs(this.basePath + "/downloads/archives", 0775);
- FILE.mkdirs(this.basePath + "/cache", 0775);
+ FILE.mkdirs(this.basePath + "/downloads/files", parseInt("0775"));
+ FILE.mkdirs(this.basePath + "/downloads/packages", parseInt("0775"));
+ FILE.mkdirs(this.basePath + "/downloads/archives", parseInt("0775"));
+ FILE.mkdirs(this.basePath + "/cache", parseInt("0775"));
}
type = type || "source";
@@ -164,7 +164,7 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
if (FILE.exists(sourcePath + packageTestFilepath))
{
callback(sourcePath);
- return;
+ return false;
}
if (typeof options.extract === "function")
@@ -186,31 +186,35 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
{
if (/gunzip: command not found/.test(stderr))
{
- return throwError("UNIX Command not found: gunzip");
+ throwError("UNIX Command not found: gunzip");
+ return;
}
else
if (stderr)
{
- FILE.mkdirs(sourcePath, 0775);
+ FILE.mkdirs(sourcePath, parseInt("0775"));
// ZIP File
SYSTEM.exec("unzip -qq -o " + archivePath + " -d " + sourcePath, function(stdout, stderr)
{
if (/unzip: command not found/.test(stderr))
{
cleanup();
- return throwError("UNIX Command not found: unzip");
+ throwError("UNIX Command not found: unzip");
+ return;
}
else
if (stderr)
{
cleanup();
- return throwError("Error extracting file '" + archivePath + "': " + stderr);
+ throwError("Error extracting file '" + archivePath + "': " + stderr);
+ return;
}
else
if (!FILE.exists(sourcePath))
{
cleanup();
- return throwError("Error extracting file '" + archivePath) + "' to '" + sourcePath + "'.";
+ throwError("Error extracting file '" + archivePath) + "' to '" + sourcePath + "'.";
+ return;
}
// See if archive has a directory containing our package
@@ -222,7 +226,8 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
if (!FILE.exists(sourcePath + packageTestFilepath))
{
cleanup();
- return throwError("Cannot find " + packageTestFilepath + " in extracted archive: " + sourcePath + packageTestFilepath);
+ throwError("Cannot find " + packageTestFilepath + " in extracted archive: " + sourcePath + packageTestFilepath);
+ return;
}
SYSTEM.exec("mv " + sourcePath + "/*/.* " + sourcePath + "/", function(stdout, stderr)
@@ -240,25 +245,28 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
else
{
// TGZ file
- FILE.mkdirs(sourcePath, 0775);
+ FILE.mkdirs(sourcePath, parseInt("0775"));
SYSTEM.exec("tar -zxf " + archivePath + " -C " + sourcePath, function(stdout, stderr)
{
if (/tar: command not found/.test(stderr))
{
cleanup();
- return throwError("UNIX Command not found: tar");
+ throwError("UNIX Command not found: tar");
+ return;
}
else
if (stderr)
{
cleanup();
- return throwError("Error extracting file '" + archivePath + "': " + stderr);
+ throwError("Error extracting file '" + archivePath + "': " + stderr);
+ return;
}
else
if (!FILE.exists(sourcePath))
{
cleanup();
- return throwError("Error extracting file '" + archivePath) + "' to '" + sourcePath + "'.";
+ throwError("Error extracting file '" + archivePath) + "' to '" + sourcePath + "'.";
+ return;
}
// See if archive has a directory containing our package
@@ -270,7 +278,8 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
if (!FILE.exists(sourcePath + packageTestFilepath))
{
cleanup();
- return throwError("Cannot find " + packageTestFilepath + " in extracted archive: " + sourcePath + packageTestFilepath);
+ throwError("Cannot find " + packageTestFilepath + " in extracted archive: " + sourcePath + packageTestFilepath);
+ return;
}
SYSTEM.exec("mv " + sourcePath + "/*/.* " + sourcePath + "/", function(stdout, stderr)
@@ -287,13 +296,15 @@ Downloader.prototype.getForArchive = function(archive, callback, options)
}
});
}
+ // To avoid strict warning
+ return false;
}
var archivePath = self.pathForURL(archive, "archive");
if (!FILE.exists(archivePath))
{
- FILE.mkdirs(FILE.dirname(archivePath), 0775);
+ FILE.mkdirs(FILE.dirname(archivePath), parseInt("0775"));
DEBUG.print("Downloading: " + archive);
@@ -324,7 +335,7 @@ Downloader.prototype.getFileForURL = function(url, callback)
return;
}
- FILE.mkdirs(FILE.dirname(path), 0775);
+ FILE.mkdirs(FILE.dirname(path), parseInt("0775"));
DEBUG.print("Downloading: " + url);
@@ -387,7 +398,7 @@ Downloader.prototype.doDownload = function(url, path, callback)
{
if (FILE.exists(cachePath))
{
- API.FILE.mkdirs(API.FILE.dirname(path), 0775);
+ API.FILE.mkdirs(API.FILE.dirname(path), parseInt("0775"));
SYSTEM.exec("cp " + cachePath + " " + path, function(stdout, stderr)
{
delete currentlyDownloading[url + "::" + path];
@@ -401,7 +412,7 @@ Downloader.prototype.doDownload = function(url, path, callback)
{
if (USE_CACHE)
{
- API.FILE.mkdirs(API.FILE.dirname(cachePath), 0775);
+ API.FILE.mkdirs(API.FILE.dirname(cachePath), parseInt("0775"));
SYSTEM.exec("cp " + path + " " + cachePath, function(stdout, stderr)
{
delete currentlyDownloading[url + "::" + path];
View
15 lib/pinf-loader-js/loader.js
@@ -52,6 +52,16 @@ var boot = exports.boot = function(options)
{
adapter = "jetpack";
}
+ // Test for GPSEE
+ if (!adapter) {
+ try {
+ var systemId = "system";
+ if (require(systemId).platform.indexOf("gpsee") >= 0)
+ {
+ adapter = "gpsee";
+ }
+ } catch(e) {}
+ }
// Test for NodeJS
if (!adapter) {
try {
@@ -62,6 +72,7 @@ var boot = exports.boot = function(options)
}
} catch(e) {}
}
+ // Test for RingoJS
if (!adapter) {
try {
var ringoArgsId = "ringo/args";
@@ -98,7 +109,7 @@ var boot = exports.boot = function(options)
{
// We are most likely running in a browser
}
- if (!adapter)
+ if (!adapter)
throw new Error("Cannot select platform adapter. Unable to identify host JavaScript platform.");
// Normalize JS environment to ES5
@@ -352,7 +363,7 @@ var boot = exports.boot = function(options)
API.FILE.remove(cliOptions["link-program-to"]);
} else
if (!API.FILE.exists(API.FILE.dirname(cliOptions["link-program-to"])))
- API.FILE.mkdirs(API.FILE.dirname(cliOptions["link-program-to"]), 0775);
+ API.FILE.mkdirs(API.FILE.dirname(cliOptions["link-program-to"]), parseInt("0775"));
API.SYSTEM.exec("ln -s " + API.FILE.dirname(path) + " " + cliOptions["link-program-to"], function(stdout, stderr)
{
Please sign in to comment.
Something went wrong with that request. Please try again.