Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Phonegap application #656

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions Libraries/JSIL.Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,16 @@ JSIL.ImplementExternals("System.Math", function ($) {
return result;
}
);


$.Method({Static:true , Public:true }, "Round",
(new JSIL.MethodSignature($jsilcore.TypeRef("System.Decimal"), [$jsilcore.TypeRef("System.Decimal"), $.Int32], [])),
function Round (value, digits) {
var multiplier = Math.pow(10, digits);
var result = Math.round(value * multiplier) / multiplier;
return result;
}
);

$.Method({Static:true , Public:true }, "Atan2",
(new JSIL.MethodSignature($.Double, [$.Double, $.Double], [])),
Math.atan2
Expand Down Expand Up @@ -2142,6 +2151,27 @@ JSIL.MakeStruct("System.ValueType", "System.Decimal", true, [], function ($) {
ctorImpl
);

$.Method({Static:true , Public:true }, "op_LessThan",
(new JSIL.MethodSignature($.Boolean, [$.Type, $.Type], [])),
function (lhs, rhs) {
return decimalToNumber(lhs) < decimalToNumber(rhs);
}
);

$.Method({Static:true , Public:true }, "op_LessThanOrEqual",
(new JSIL.MethodSignature($.Boolean, [$.Type, $.Type], [])),
function (lhs, rhs) {
return decimalToNumber(lhs) <= decimalToNumber(rhs);
}
);

$.Method({Static:true , Public:true }, "op_GreaterThan",
(new JSIL.MethodSignature($.Boolean, [$.Type, $.Type], [])),
function (lhs, rhs) {
return decimalToNumber(lhs) > decimalToNumber(rhs);
}
);

$.Method({Static:true , Public:true }, "op_Equality",
(new JSIL.MethodSignature($.Boolean, [$.Type, $.Type], [])),
function (lhs, rhs) {
Expand Down Expand Up @@ -2183,7 +2213,12 @@ JSIL.MakeStruct("System.ValueType", "System.Decimal", true, [], function ($) {
return numberToDecimal(decimalToNumber(lhs) - decimalToNumber(rhs));
}
);


$.Method({Static:true , Public:true }, "op_Implicit",
(new JSIL.MethodSignature($.Type, [mscorlib.TypeRef("System.Int32")], [])),
numberToDecimal
);

$.Method({Static:true , Public:true }, "op_Explicit",
(new JSIL.MethodSignature($.Type, [mscorlib.TypeRef("System.Single")], [])),
numberToDecimal
Expand Down Expand Up @@ -3507,6 +3542,20 @@ JSIL.ImplementExternals(
return result;
}
);

$.Method({ Static: false, Public: true, Virtual: true }, "CompareTo",
new JSIL.MethodSignature($jsilcore.TypeRef("System.Int32"), [$jsilcore.TypeRef("System.Object")]),
function (enm) {
if (this.value < enm.value) {
return -1;
}
if (this.value > enm.value) {
return 1;
}
return 0;
}
);

}
);

Expand Down
13 changes: 13 additions & 0 deletions Libraries/JSIL.WebWorker.Loaders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var assetLoaders = {
"Library": function loadLibrary (filename, data, onError, onDoneLoading, state) {
var uri = jsilConfig.libraryRoot + filename;
importScripts(uri);
},
"Script": function loadScript (filename, data, onError, onDoneLoading, state) {
var uri = jsilConfig.scriptRoot + filename;
importScripts(uri);
},
};

function initAssetLoaders () {
};
100 changes: 100 additions & 0 deletions Libraries/JSIL.WebWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"use strict";

JSIL.DeclareNamespace("JSIL.WebWorker", false);

JSIL.WebWorker.StdOutService = function () {
};

JSIL.WebWorker.StdOutService.prototype.write = function (text) {
postMessage("output " + text);
};


JSIL.WebWorker.StdErrService = function () {
};

JSIL.WebWorker.StdErrService.prototype.write = function (text) {
var trimmed = String(text).trim();
if (trimmed[trimmed.length - 1] === "\n") {
text = trimmed.substr(0, trimmed.length - 1);
}

postMessage("error " + text);
};

(function () {
JSIL.Host.registerServices({
stdout: new JSIL.WebWorker.StdOutService(),
stderr: new JSIL.WebWorker.StdErrService()
});
})();

function reportException (e) {
var stack = "";
try {
stack = e.stack || "";
} catch (ex) {
stack = "";
}

JSIL.Host.logWriteLine("// EXCEPTION:");
JSIL.Host.logWriteLine(String(e));
if (stack.length > 0) {
JSIL.Host.logWriteLine("// STACK:");
JSIL.Host.logWriteLine(stack);
}
JSIL.Host.logWriteLine("// ENDEXCEPTION");

throw e;
};

function loadAssets (assets) {
for (var i = 0, l = assets.length; i < l; i++) {
var assetSpec = assets[i];

var assetType = assetSpec[0];
var assetPath = assetSpec[1];
var assetData = assetSpec[2] || null;

var assetLoader = assetLoaders[assetType];

assetLoader(assetPath, assetData);
}
};

// onLoad will be called from the worker.
var onLoad = function () {
initAssetLoaders();

var seenFilenames = {};

var pushAsset = function (assetSpec) {
var filename = assetSpec[1];
if (seenFilenames[filename])
return;

seenFilenames[filename] = true;
allAssetsToLoad.push(assetSpec);
}

var allAssetsToLoad = [];

if (typeof (assetsToLoad) !== "undefined") {
for (var i = 0, l = assetsToLoad.length; i < l; i++)
pushAsset(assetsToLoad[i]);
}

if (typeof (contentManifest) === "object") {
for (var k in contentManifest) {
var subManifest = contentManifest[k];

for (var i = 0, l = subManifest.length; i < l; i++)
pushAsset(subManifest[i]);

}
}

loadAssets(allAssetsToLoad);
JSIL.Initialize();
JSIL.Host.runInitCallbacks();
};
26 changes: 25 additions & 1 deletion Libraries/JSIL.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,34 @@ var $jsilloaderstate = {
this.loadScript(libraryRoot + "JSIL.Shell.Loaders.js");
};

function Environment_WebWorker (config) {
var self = this;
this.config = config;

contentManifest["JSIL"].push(["Library", "JSIL.Storage.js"]);
contentManifest["JSIL"].push(["Library", "JSIL.IO.js"]);
contentManifest["JSIL"].push(["Library", "JSIL.XML.js"]);
};

Environment_WebWorker.prototype.getUserSetting = function (key) {
// FIXME
return false;
};

Environment_WebWorker.prototype.loadScript = function (uri) {
importScripts(uri);
};

Environment_WebWorker.prototype.loadEnvironmentScripts = function () {
this.loadScript(libraryRoot + "JSIL.WebWorker.js");
this.loadScript(libraryRoot + "JSIL.WebWorker.Loaders.js");
};


var environments = {
"browser": Environment_Browser,
"spidermonkey_shell": Environment_SpidermonkeyShell
"spidermonkey_shell": Environment_SpidermonkeyShell,
"webworker": Environment_WebWorker
}

if (!config.environment) {
Expand Down