Permalink
Browse files

Stub out File. CreateText and AppendText

Stub out String.CopyTo and String.Join
Default-init jsilConfig.contentRoot
Fix bug in getImageTopLeftPixel
  • Loading branch information...
1 parent 5ad89db commit 9a97a1a14506a299fe3727b0822dec7bf2a72e57 @kg kg committed Aug 18, 2012
Showing with 154 additions and 106 deletions.
  1. +14 −0 Libraries/JSIL.Bootstrap.js
  2. +14 −0 Libraries/JSIL.IO.js
  3. +14 −4 Libraries/JSIL.XNACore.js
  4. +103 −102 Libraries/JSIL.js
  5. +9 −0 Proxies/String.cs
@@ -829,6 +829,16 @@ JSIL.ImplementExternals(
return str + makePadding(ch, extraChars);
}
);
+
+ $.Method({Static: true , Public: true }, "CopyTo",
+ new JSIL.MethodSignature(null, ["System.String"], [], $jsilcore),
+ function (str, sourceIndex, destination, destinationIndex, count) {
+ if (count > 0) {
+ for (var i = 0; i < count; i++)
+ destination[destinationIndex + i] = str[sourceIndex + i];
+ }
+ }
+ );
}
);
@@ -1197,6 +1207,10 @@ JSIL.SplitString = function (str, separators) {
return str.split(separators[0]);
};
+JSIL.JoinStrings = function (separator, strings) {
+ return strings.join(separator);
+};
+
JSIL.ConcatString = function (/* ...values */) {
var result = String(arguments[0]);
View
@@ -137,6 +137,20 @@ JSIL.ImplementExternals("System.IO.File", function ($) {
}
);
+ $.Method({Static:true , Public:true }, "CreateText",
+ (new JSIL.MethodSignature($jsilcore.TypeRef("System.IO.StreamWriter"), [$.String], [])),
+ function AppendText (path) {
+ return new System.IO.StreamWriter(path, true);
+ }
+ );
+
+ $.Method({Static:true , Public:true }, "CreateText",
+ (new JSIL.MethodSignature($jsilcore.TypeRef("System.IO.StreamWriter"), [$.String], [])),
+ function CreateText (path) {
+ return new System.IO.StreamWriter(path, false);
+ }
+ );
+
$.Method({Static:true , Public:true }, "Delete",
(new JSIL.MethodSignature(null, [$.String], [])),
function Delete (path) {
View
@@ -362,7 +362,7 @@ $jsilxna.getImageTopLeftPixel = function (image) {
return cached;
var canvas = document.createElement("canvas");
- var context = $jsilxna.get2DContext(image, false);
+ var context = $jsilxna.get2DContext(canvas, false);
canvas.width = 1;
canvas.height = 1;
@@ -3272,8 +3272,6 @@ JSIL.ImplementExternals("Microsoft.Xna.Framework.Game", function ($) {
ctx.fillStyle = "black";
ctx.fillRect(0, 0, 99999, 99999);
- canvas.style.display = "none";
-
var fsb = document.getElementById("fullscreenButton");
if (fsb)
fsb.style.display = "none";
@@ -4462,7 +4460,7 @@ $jsilxna.Color = function ($) {
$.Method({
Static: true,
Public: true
- }, "op_Multiply", new JSIL.MethodSignature($.Type, [$.Type, $.Single], []), function (color, multiplier) {
+ }, "op_Multiply", new JSIL.MethodSignature($jsilxna.colorRef(), [$jsilxna.colorRef(), $.Single], []), function (color, multiplier) {
var result = Object.create(Object.getPrototypeOf(color));
result.a = $jsilxna.ClampByte(color.a * multiplier);
result.r = $jsilxna.ClampByte(color.r * multiplier);
@@ -4471,6 +4469,18 @@ $jsilxna.Color = function ($) {
return result;
});
+ $.Method({
+ Static: true,
+ Public: true
+ }, "Lerp", new JSIL.MethodSignature($jsilxna.colorRef(), [$jsilxna.colorRef(), $jsilxna.colorRef(), $.Single], []), function (a, b, amount) {
+ var result = Object.create(Object.getPrototypeOf(a));
+ result.a = $jsilxna.ClampByte(a.a + (b.a - a.a) * amount);
+ result.r = $jsilxna.ClampByte(a.r + (b.r - a.r) * amount);
+ result.g = $jsilxna.ClampByte(a.g + (b.g - a.g) * amount);
+ result.b = $jsilxna.ClampByte(a.b + (b.b - a.b) * amount);
+ return result;
+ });
+
$.RawMethod(false, "toCss", function (alpha) {
if ((typeof(this._cachedCss) === "string") && (this._cachedAlpha === alpha)) {
return this._cachedCss;
View
@@ -6,117 +6,118 @@
//
if (typeof (contentManifest) !== "object") {
- contentManifest = {};
+ contentManifest = {};
};
contentManifest["JSIL"] = [
["Library", "JSIL.Storage.js"],
["Library", "JSIL.IO.js"],
- ["Library", "JSIL.JSON.js"],
+ ["Library", "JSIL.JSON.js"],
["Library", "JSIL.XML.js"]
];
(function loadJSIL (config) {
- if (config.showFullscreenButton) {
- document.write(
- '<button id="fullscreenButton">Full Screen</button>'
- );
- }
-
- if (config.showStats) {
- document.write(
- '<div id="stats"></div>'
- );
- }
-
- if (config.showProgressBar) {
- document.write(
- '<div id="loadingProgress">' +
- ' <div id="progressBar"></div>' +
- ' <span id="progressText"></span>' +
- '</div>'
- );
-
- }
-
- var libraryRoot = (config.libraryRoot = config.libraryRoot || "../Libraries/");
- var manifestRoot = (config.manifestRoot = config.manifestRoot || "");
- config.scriptRoot = config.scriptRoot || "";
- config.fileRoot = config.fileRoot || "";
- config.assetRoot = config.assetRoot || "";
-
- function loadScript (uri) {
- if (window.console && window.console.log)
- window.console.log("Loading '" + uri + "'...");
-
- document.write(
- "<script type=\"text/javascript\" src=\"" + uri + "\"></script>"
- );
- };
-
- if (config.printStackTrace)
- loadScript(libraryRoot + "printStackTrace.js");
-
- if (config.webgl2d)
- loadScript(libraryRoot + "webgl-2d.js");
-
- loadScript(libraryRoot + "JSIL.Core.js");
- loadScript(libraryRoot + "JSIL.Bootstrap.js");
- loadScript(libraryRoot + "JSIL.Browser.js");
-
- if (config.testFixture || (document.location.search.indexOf("testFixture") >= 0)) {
- loadScript(libraryRoot + "JSIL.TestFixture.js");
- }
-
- var manifests = config.manifests || [];
-
- for (var i = 0, l = manifests.length; i < l; i++)
- loadScript(manifestRoot + manifests[i] + ".manifest.js");
-
- if (config.winForms) {
- contentManifest["JSIL"].push(
- ["Library", "System.Drawing.js"]
- );
- contentManifest["JSIL"].push(
- ["Library", "System.Windows.js"]
- );
- }
-
- if (config.xna) {
- contentManifest["JSIL"].push(
- ["Library", "JSIL.XNACore.js"]
- );
-
- switch (Number(config.xna)) {
- case 3:
- contentManifest["JSIL"].push(
- ["Library", "JSIL.XNA3.js"]
- );
- break;
- case 4:
- contentManifest["JSIL"].push(
- ["Library", "JSIL.XNA4.js"]
- );
- break;
- default:
- throw new Error("Unsupported XNA version");
- }
-
- contentManifest["JSIL"].push(
- ["Library", "JSIL.XNAStorage.js"]
- );
- }
-
- if (config.readOnlyStorage) {
- contentManifest["JSIL"].push(
- ["Library", "JSIL.ReadOnlyStorage.js"]
- );
- }
-
- if (config.localStorage) {
- contentManifest["JSIL"].push(
- ["Library", "JSIL.LocalStorage.js"]
+ if (config.showFullscreenButton) {
+ document.write(
+ '<button id="fullscreenButton">Full Screen</button>'
+ );
+ }
+
+ if (config.showStats) {
+ document.write(
+ '<div id="stats"></div>'
+ );
+ }
+
+ if (config.showProgressBar) {
+ document.write(
+ '<div id="loadingProgress">' +
+ ' <div id="progressBar"></div>' +
+ ' <span id="progressText"></span>' +
+ '</div>'
+ );
+
+ }
+
+ var libraryRoot = (config.libraryRoot = config.libraryRoot || "../Libraries/");
+ var manifestRoot = (config.manifestRoot = config.manifestRoot || "");
+ config.scriptRoot = config.scriptRoot || "";
+ config.fileRoot = config.fileRoot || "";
+ config.assetRoot = config.assetRoot || "";
+ config.contentRoot = config.contentRoot || "Content/";
+
+ function loadScript (uri) {
+ if (window.console && window.console.log)
+ window.console.log("Loading '" + uri + "'...");
+
+ document.write(
+ "<script type=\"text/javascript\" src=\"" + uri + "\"></script>"
+ );
+ };
+
+ if (config.printStackTrace)
+ loadScript(libraryRoot + "printStackTrace.js");
+
+ if (config.webgl2d)
+ loadScript(libraryRoot + "webgl-2d.js");
+
+ loadScript(libraryRoot + "JSIL.Core.js");
+ loadScript(libraryRoot + "JSIL.Bootstrap.js");
+ loadScript(libraryRoot + "JSIL.Browser.js");
+
+ if (config.testFixture || (document.location.search.indexOf("testFixture") >= 0)) {
+ loadScript(libraryRoot + "JSIL.TestFixture.js");
+ }
+
+ var manifests = config.manifests || [];
+
+ for (var i = 0, l = manifests.length; i < l; i++)
+ loadScript(manifestRoot + manifests[i] + ".manifest.js");
+
+ if (config.winForms) {
+ contentManifest["JSIL"].push(
+ ["Library", "System.Drawing.js"]
+ );
+ contentManifest["JSIL"].push(
+ ["Library", "System.Windows.js"]
+ );
+ }
+
+ if (config.xna) {
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.XNACore.js"]
+ );
+
+ switch (Number(config.xna)) {
+ case 3:
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.XNA3.js"]
);
- }
+ break;
+ case 4:
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.XNA4.js"]
+ );
+ break;
+ default:
+ throw new Error("Unsupported XNA version");
+ }
+
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.XNAStorage.js"]
+ );
+ }
+
+ if (config.readOnlyStorage) {
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.ReadOnlyStorage.js"]
+ );
+ }
+
+ if (config.localStorage) {
+ contentManifest["JSIL"].push(
+ ["Library", "JSIL.LocalStorage.js"]
+ );
+ }
})(jsilConfig || {});
View
@@ -79,6 +79,10 @@ public abstract class StringProxy {
[JSReplacement("JSIL.SplitString($this, $dividers)")]
public abstract string[] Split (AnyType[] dividers);
+ [JSIsPure]
+ [JSReplacement("JSIL.JoinStrings($separator, $value)")]
+ public abstract string Join (string separator, params string[] value);
+
[JSChangeName("length")]
[JSAlwaysAccessAsProperty]
[JSNeverReplace]
@@ -296,5 +300,10 @@ public abstract class StringProxy {
public string Remove (int startIndex, int count) {
throw new InvalidOperationException();
}
+
+ [JSReplacement("System.String.CopyTo($this, $sourceIndex, $destination, $destinationIndex, $count)")]
+ public void CopyTo (int sourceIndex, char[] destination, int destinationIndex, int count) {
+ throw new InvalidOperationException();
+ }
}
}

0 comments on commit 9a97a1a

Please sign in to comment.