This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 242
Char based on number #938
Open
iskiselev
wants to merge
7
commits into
sq:master
Choose a base branch
from
iskiselev:CharBasedOnNumber
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Char based on number #938
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12e3a9b
Char base type changed to Number.
iskiselev c1a2caa
JSIL.ConcatString fixed.
iskiselev 6b15238
JSIL.StringFromCharArray fixed.
iskiselev ed1cfb7
Int64 -> Char cast.
iskiselev d44cb01
Fixed rebase problems with char.
iskiselev 7a8a2cc
Implemented special processing for ToString.
iskiselev 842573b
JSReplacement doesn't affect output translation.
iskiselev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
JSIL.Libraries/Includes/Bootstrap/Core/Classes/JSIL.StringEnumerator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
JSIL.MakeClass("System.Object", "JSIL.StringEnumerator", true, ["T"], function ($) { | ||
var T = new JSIL.GenericParameter("T", "JSIL.StringEnumerator"); | ||
|
||
$.RawMethod(false, "__CopyMembers__", | ||
function ArrayEnumerator_CopyMembers(source, target) { | ||
target._array = source._array; | ||
target._length = source._length; | ||
target._index = source._index; | ||
} | ||
); | ||
|
||
$.Method({ Public: true, Static: false }, ".ctor", | ||
new JSIL.MethodSignature(null, [$jsilcore.TypeRef("System.Array", ["!!0"]), $.Int32]), | ||
function (array, startPosition) { | ||
this._array = array; | ||
this._length = array.length; | ||
if (typeof (startPosition) !== "number") | ||
JSIL.RuntimeError("ArrayEnumerator ctor second argument must be number"); | ||
|
||
this._index = startPosition; | ||
} | ||
); | ||
|
||
$.Method({ Public: true, Static: false }, "Reset", | ||
new JSIL.MethodSignature(null, []), | ||
function () { | ||
if (this._array === null) | ||
JSIL.RuntimeError("Enumerator is disposed or not initialized"); | ||
|
||
this._index = -1; | ||
} | ||
); | ||
|
||
$.Method({ Public: true, Static: false }, "MoveNext", | ||
new JSIL.MethodSignature(System.Boolean, []), | ||
function () { | ||
return (++this._index < this._length); | ||
} | ||
); | ||
|
||
$.Method({ Public: true, Static: false }, "Dispose", | ||
new JSIL.MethodSignature(null, []), | ||
function () { | ||
this._array = null; | ||
this._index = 0; | ||
this._length = -1; | ||
} | ||
); | ||
|
||
$.Method({ Public: false, Static: false }, null, | ||
new JSIL.MethodSignature(System.Object, []), | ||
function () { | ||
return this._array.charCodeAt(this._index); | ||
} | ||
) | ||
.Overrides("System.Collections.IEnumerator", "get_Current"); | ||
|
||
$.Method({ Public: true, Static: false }, "get_Current", | ||
new JSIL.MethodSignature(T, []), | ||
function () { | ||
return this._array.charCodeAt(this._index); | ||
} | ||
) | ||
.Overrides("System.Collections.Generic.IEnumerator`1", "get_Current"); | ||
|
||
$.Property({ Public: true, Static: false, Virtual: true }, "Current"); | ||
|
||
$.ImplementInterfaces( | ||
/* 0 */ System.IDisposable, | ||
/* 1 */ System.Collections.IEnumerator, | ||
/* 2 */ $jsilcore.TypeRef("System.Collections.Generic.IEnumerator`1", [new JSIL.GenericParameter("T", "JSIL.StringEnumerator")]) | ||
); | ||
}); |
4 changes: 2 additions & 2 deletions
4
JSIL.Libraries/Includes/Bootstrap/Core/Classes/System.Char.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
JSIL.ImplementExternals( | ||
"System.Char", function ($) { | ||
$.RawMethod(true, "CheckType", function (value) { | ||
return ((typeof (value) === "string") && (value.length == 1)) || JSIL.Box.IsBoxedOfType(value, $.Type); | ||
return (typeof (value) === "number") || JSIL.Box.IsBoxedOfType(value, $.Type); | ||
}); | ||
|
||
$.Constant({ Public: true, Static: true }, "MaxValue", "\uffff"); | ||
$.Constant({ Public: true, Static: true }, "MinValue", "\0"); | ||
} | ||
); | ||
JSIL.MakeNumericType(String, "System.Char", true, null, JSIL.MakeIConvertibleMethods); | ||
JSIL.MakeNumericType(Number, "System.Char", true, null, JSIL.MakeIConvertibleMethods); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches .NET, right? re: surrogate pairs, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it additionally, but really .Net strings (same as JS string) knows nothing about surrogate pairs.
So, it should just break them into two Chars (and Char is unable to represent surrogate pair, as it only Int16, and we need Int32 for surrogate pairs).