Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case 'Linux':
platLibName = 'libnacl-' + platCode + '.so';
break;
case 'Darwin':
if (numbits !== 64)
throw new Error('32-bit OS X not supported right now.');
platLibName = 'libnacl-x86_64.dylib';
break;
case 'Android':
platLibName = 'libnacl-arm.so';
break;
default:
throw new Error('No native library for platform: ' + runtime.OS);
}
// NOTE: the libs now get packaged in the data sub-tree!
let path = $url.toFilename(
$self.data.url("nacl-native-libs/" + platLibName).toString());
let NACL = $ctypes.open(path);
$unload.when(function() {
NACL.close();
});
////////////////////////////////////////////////////////////////////////////////
// Strings, Types
const pustr = $ctypes.unsigned_char.ptr,
Sizey = $ctypes.unsigned_long_long;
function ustr_t(x) {
return $ctypes.unsigned_char.array(x);
function getDataFile(filename) {
var myFilename = require("url").toFilename(__url__);
var file = Cc['@mozilla.org/file/local;1']
.createInstance(Ci.nsILocalFile);
file.initWithPath(myFilename);
file = file.parent.parent;
file.append('examples');
file.append('sample-web-page');
file.append(filename);
return file;
}
function() { url.toFilename("resource://nonexistent"); },
"resource does not exist: resource://nonexistent/",
function embedMozAppsAPIFiles(destDir)
{
//this is slightly sketchy, going up out of the data dir and into the lib dir to fetch a file...
let dataURL = self.data.url(".");
let dataPath = url.toFilename(dataURL);
let injectorSrc = Cc['@mozilla.org/file/local;1']
.createInstance(Ci.nsILocalFile);
injectorSrc.initWithPath(dataPath);
injectorSrc = injectorSrc.parent;
injectorSrc.append("lib");
injectorSrc.append("injector.js");
var injectorDest = destDir.clone();
injectorDest.append("injector.js");
copyFile(injectorSrc.path, injectorDest.path);
}
addon.registerCall("self:load", function(name, path, stack) {
let data_url = getURL(path, stack, 1);
let fn = url.toFilename(data_url);
let data = file.read(fn);
return data;
});
addon.registerCall("self:url", function(name, path, stack) {
load: function load(name) {
let data_url = getURL(name, 1);
let fn = url.toFilename(data_url);
let data = file.read(fn);
return data;
},
url: function url(name) { return getURL(name, 1); }
exports.get = function get() {
if (!component) {
var path = url.toFilename(url.URL("platform", __url__).toString());
xpcom.autoRegister(path);
var factory = xpcom.getClass("@labs.mozilla.com/jetpackdi;1",
Ci.nsIFactory);
var nsJetpack = factory.createInstance(null, Ci.nsISupports);
component = nsJetpack.get();
}
return component;
};