-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow attributing a function to specify that its return value is a pa…
…cked array. Safety check return statements within functions to ensure that packed arrays are not returned as normal arrays or vice versa.
- Loading branch information
Showing
6 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using JSIL.Meta; | ||
|
||
public struct IntFloatPair { | ||
public int Int; | ||
public float Float; | ||
|
||
public override string ToString () { | ||
return String.Format("Int={0:0000}, Float={1:000.000}", Int, Float); | ||
} | ||
} | ||
|
||
public static class Program { | ||
public static IntFloatPair[] PackedArray = new IntFloatPair[2]; | ||
|
||
public static unsafe void Main (string[] args) { | ||
var pa = ReturnPackedArray(); | ||
|
||
foreach (var item in pa) | ||
Console.WriteLine(item); | ||
} | ||
|
||
[JSPackedArrayReturnValue] | ||
public static IntFloatPair[] ReturnPackedArray () { | ||
return PackedArray; | ||
} | ||
} |
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,27 @@ | ||
using System; | ||
using JSIL.Meta; | ||
|
||
public struct IntFloatPair { | ||
public int Int; | ||
public float Float; | ||
|
||
public override string ToString () { | ||
return String.Format("Int={0:0000}, Float={1:000.000}", Int, Float); | ||
} | ||
} | ||
|
||
public static class Program { | ||
[JSPackedArray] | ||
public static IntFloatPair[] PackedArray = new IntFloatPair[2]; | ||
|
||
public static unsafe void Main (string[] args) { | ||
var pa = ReturnPackedArray(); | ||
|
||
foreach (var item in pa) | ||
Console.WriteLine(item); | ||
} | ||
|
||
public static IntFloatPair[] ReturnPackedArray () { | ||
return PackedArray; | ||
} | ||
} |
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