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

Bootstrap from C#. Number formats #857

Merged
merged 22 commits into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
de74cba
Introduced solution folders: Dependecies, Libraries, Tests
iskiselev Sep 15, 2015
3d09504
Added JSRepaceAssemblyDeclaration meta attibute.
iskiselev Sep 16, 2015
a9a5dd2
TypeDeclarationsToSuppress logic moved to JSSuppressTypeDeclaration m…
iskiselev Sep 16, 2015
ee8a52f
Added JSImportType meta attribute.
iskiselev Sep 16, 2015
82a2b6b
JSOverrideAssemblyReference meta attribute introduced.
iskiselev Sep 17, 2015
baa7349
Generate JSIL.Bootstrap.Int64.js using its parts.
iskiselev Sep 17, 2015
6e0ae8d
StringBuilder.Remove implemented.
iskiselev Sep 17, 2015
1b0461a
Fixed UInt64 creation (#855)
iskiselev Sep 17, 2015
efdc5d3
Added JSIL.mscorlib project with number formatter implementation.
iskiselev Sep 17, 2015
f28b6a3
Overwrite defaults.jsilconfig if newer only.
iskiselev Sep 17, 2015
e26e255
Use number .ToString formats from Mono.
iskiselev Sep 17, 2015
b008884
Compatibility with translated/stubbed.
iskiselev Sep 17, 2015
03ce404
StringBuilder.Insert implemented.
iskiselev Sep 17, 2015
7d2a499
Fix handling JSON config on mono.
iskiselev Sep 18, 2015
be94f67
Don't try to write method body for stubbed proxied methods.
iskiselev Sep 18, 2015
43f481c
Added signatures for all numeric types.
iskiselev Sep 18, 2015
e16b920
Analyze imported functions on translation step.
iskiselev Sep 19, 2015
3866087
Temporary marked IntegerToStringFormatted as FailsOnMono.
iskiselev Sep 19, 2015
83672d3
Use mono formatters for non-integer types.
iskiselev Sep 19, 2015
0c8daa5
Parse(string, IFormatProvider) override added.
iskiselev Oct 4, 2015
6e3367a
PR review fixes.
iskiselev Oct 8, 2015
7cf2a8e
Double parse signature fixed.
iskiselev Oct 4, 2015
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Tests.DCE/obj
Tests.DCE//bin
JSIL.Libraries/node_modules
JSIL.Libraries/obj
JSIL.Libraries/Generated
JSIL.Libraries/bin
Libraries/
.vs/
/mono
/mono
JSIL.mscorlib/obj/
JSIL.mscorlib/bin/
2 changes: 1 addition & 1 deletion Compiler/Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<SubType>Designer</SubType>
</None>
<None Include="defaults.jsilconfig">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion Compiler/defaults.jsilconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ProxyWarnings": false,
"Assemblies": {
"Stubbed": [
"mscorlib,",
"^mscorlib,",
"^System,",
"^System\\.(.+),",
"^Microsoft\\.(.+),",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ JSIL.ImplementExternals("System.BitConverter", function ($) {
(new JSIL.MethodSignature($.Double, [$jsilcore.TypeRef("System.Array", [$.Byte]), $.Int32], [])),
$jsilcore.BytesToDouble
);

$.Method({ Static: true, Public: true }, "DoubleToInt64Bits",
(new JSIL.MethodSignature($.Int64, [$.Double], [])),
function DoubleToInt64Bits(double) {
return $jsilcore.BytesToInt64($jsilcore.BytesFromDouble(double), 0);
}
);
});

//? if ('GENERATE_STUBS' in __out) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ JSIL.ImplementExternals("System.UInt64", function ($) {
$.Method({ Static: true, Public: false }, "FromNumber",
(new JSIL.MethodSignature($.Type, [$.Double], [])),
function UInt64_FromNumber(n) {
return me().FromNumberImpl(n, ctor);
var sum = n < 0 ? 0x100000000 : 0;
return me().FromNumberImpl(sum + n, ctor);
});

// Not present in mscorlib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,23 @@ JSIL.ImplementExternals("System.Globalization.CultureInfo", function ($) {
return $jsilcore.System.Globalization.CultureInfo.GetCultureInfo(name);
}
);


$.Method({ Static: false, Public: true }, "get_IsReadOnly",
(new JSIL.MethodSignature($.Boolean, [], [])),
function get_IsReadOnly() {
return true;
}
);

$.Method({ Static: false, Public: true }, "get_NumberFormat",
(new JSIL.MethodSignature($jsilcore.TypeRef("System.Globalization.NumberFormatInfo"), [], [])),
function get_NumberFormat() {
if (this.numInfo === null) {
this.numInfo = new $jsilcore.System.Globalization.NumberFormatInfo();
}
return this.numInfo;
}
);
});

JSIL.ImplementExternals("System.Globalization.CultureInfo", function ($) {
Expand All @@ -93,4 +109,8 @@ JSIL.ImplementExternals("System.Globalization.CultureInfo", function ($) {
return $jsilcore.getCurrentUICultureImpl();
}
);
});
});

JSIL.MakeClass("System.Object", "System.Globalization.CultureInfo", true, [], function ($) {
$.Field({ Public: false, Static: false }, "numInfo", $jsilcore.TypeRef("System.Globalization.NumberFormatInfo"));
})
2 changes: 1 addition & 1 deletion JSIL.Libraries/Includes/Bootstrap/Resources/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (!$jsilcore)

$jsilcore.getCurrentUICultureImpl = function () {
var language;
var svc = JSIL.Host.getService("window", false);
var svc = JSIL.Host.getService("window", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need initialize current culture even in non-browser environment.
Really next line even tries to do it:

  if (svc) {
    language = svc.getNavigatorLanguage() || "en-US";
  } else {
    language = "en-US";
  }

But in non-browser environment it will not return null, but fail.
Now it will return null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I probably got the second argument's boolean nature backwards... bools are awful.


if (svc) {
language = svc.getNavigatorLanguage() || "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ JSIL.ImplementExternals("System.Text.StringBuilder", function ($) {
}
);

$.Method({ Static: false, Public: true }, "Remove",
(new JSIL.MethodSignature($.Type, [$.Int32, $.Int32], [])),
function Remove(startIndex, length) {
this._str = this._str.substr(0, startIndex) + this._str.substring(startIndex + length, length);
return this;
}
);

var replace = function (self, oldText, newText, startIndex, count) {
var prefix = self._str.substr(0, startIndex);
var suffix = self._str.substr(startIndex + count);
Expand Down Expand Up @@ -328,6 +336,35 @@ JSIL.ImplementExternals("System.Text.StringBuilder", function ($) {
}
);

var insert = function (self, string, startIndex, count) {
while (startIndex > self._str.length - 1 && self._str.length < self._capacity) {
self._str += "\0";
}

var suffix = self._str.substr(startIndex);
self._str = self._str.substr(0, startIndex);
for (var i = 0; i < count; i++) {
self._str += string;
}
self._str += suffix;
self._capacity = Math.max(self._capacity, self._str.length);
return self;
};

$.Method({ Static: false, Public: true }, "Insert",
(new JSIL.MethodSignature($.Type, [$.Int32, $.String], [])),
function Insert(index, value) {
return insert(this, index, value, 1);
}
);

$.Method({ Static: false, Public: true }, "Insert",
(new JSIL.MethodSignature($.Type, [$.Int32, $.String, $.Int32], [])),
function Insert(index, value, count) {
return insert(this, index, value, count);
}
);

$.Method({ Static: false, Public: true }, "set_Length",
(new JSIL.MethodSignature(null, [$.Int32], [])),
function set_Length(value) {
Expand Down Expand Up @@ -355,6 +392,9 @@ JSIL.ImplementExternals("System.Text.StringBuilder", function ($) {
$.Method({ Static: false, Public: true }, "set_Chars",
(new JSIL.MethodSignature(null, [$.Int32, $.Char], [])),
function set_Chars(i, value) {
while (i > this._str.length - 1) {
this._str += "\0";
}
this._str =
this._str.substr(0, i) +
value +
Expand Down
13 changes: 9 additions & 4 deletions JSIL.Libraries/JSIL.Libraries.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClassLibrary1</RootNamespace>
<AssemblyName>ClassLibrary1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\</OutputPath>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>.\</OutputPath>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -325,7 +325,12 @@
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\JSIL.mscorlib\JSIL.mscorlib.csproj">
<Project>{aef2633e-e92c-4a0d-b8e0-a072ed404af7}</Project>
<Name>JSIL.mscorlib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="Targets\Empty.targets" />
<Import Project="Targets\MSBuild.Node.targets" />
<Import Project="Targets\MSBuild.Npm.targets" />
Expand Down
Loading