Open hevans90 opened 9 years ago
Check the developer console for the page and you will probably see some messages about unimplemented externals. Most likely you are hitting an unimplemented constructor, unimplemented op_Multiply, or both. (If the method is unimplemented it'll return undefined, so MemberwiseClone won't work.)
Upon checking the dev console it seems there is a bigger issue, before it aborts as shown in my first post, it fails to load my content manifest (xx.contentproj.manifest.js) because one doesn't exist! I'll have to check later why my XNA content didn't get compiled by JSIL, almost certainly my fault.
I JSIL complied from a pre-built folder containing an .exe (with a folder called 'Content' full of stuff) rather than using the .sln method.
So after some troubleshooting I managed to get my XNA content project to compile with JSIL (yay!), and now I notice some errors regarding unimplemented externals, followed by an app crash afterwards, any advice on how to combat this?
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.GameComponentCollection' has not been implemented; calling inherited method. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.$internalCtor (http://hackattack:82/JSIL/lib/XNA/XNA4.js:1117:10) at Object.Microsoft_Xna_Framework_GameComponentCollection_CreateInstanceOfType (jsil://closure/Microsoft.Xna.Framework.GameComponentCollection.CreateInstanceOfType:6:30) at Object.JSIL.CreateInstanceOfType$CacheHit (http://hackattack:82/JSIL/lib/JSIL.Core.js:8617:14) at Object.JSIL.CreateInstanceOfType$CacheMiss (http://hackattack:82/JSIL/lib/JSIL.Core.js:8593:15) at Object.JSIL.CreateInstanceOfType (http://hackattack:82/JSIL/lib/JSIL.Core.js:8643:17) at Object._ctor (http://hackattack:82/JSIL/lib/XNA/XNA4.js:1169:30 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.BlendState' has not been implemented; calling inherited method.
at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15)
at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13)
at Object.ExternalMemberStub as _ctor$void=void
at Object.Microsoft_Xna_Framework_Graphics_BlendState__ctor as _ctor
at Object.Microsoft_Xna_Framework_Graphics_BlendState (jsil://closure/Microsoft.Xna.Framework.Graphics.BlendState:15:21)
at Function.
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.GraphicsResource' has not been implemented; calling inherited method.
at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15)
at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13)
at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14)
at Object.ExternalMemberStub as _ctor$void=void
at Object.Microsoft_Xna_Framework_Graphics_BlendState__ctor as _ctor
at Object.Microsoft_Xna_Framework_Graphics_BlendState (jsil://closure/Microsoft.Xna.Framework.Graphics.BlendState:15:21)
at Function.
The external method 'void .ctor()' of type 'System.IO.Stream' has not been implemented; calling inherited method. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at ctorBytesImpl (http://hackattack:82/JSIL/lib/JSIL.IO.js:736:38) at Object._ctor as _ctor$32[622],28=void at Object.System_IO_MemoryStream__ctor as _ctor at Object.System_IO_MemoryStream (jsil://closure/System.IO.MemoryStream:21:21) at Object.RawXNBAsset_ReadAsset (http://hackattack:82/JSIL/lib/XNA/XNA4.js:163:24) at Object.ContentManager_Load [as Load$b1$30=!!0] (http://hackattack:82/JSIL/lib/XNA/Content.js:57:24 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'System.MarshalByRefObject' has not been implemented; calling inherited method. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1290:39) at ctorBytesImpl (http://hackattack:82/JSIL/lib/JSIL.IO.js:736:38) at Object._ctor as _ctor$32[622],28=void at Object.System_IO_MemoryStream__ctor as _ctor at Object.System_IO_MemoryStream (jsil://closure/System.IO.MemoryStream:21:21) at Object.RawXNBAsset_ReadAsset (http://hackattack:82/JSIL/lib/XNA/XNA4.js:163:24 JSIL.Browser.js:199
The external method 'System.Int32 ReadByte()' of type 'System.IO.MemoryStream' has not been implemented; calling inherited method. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.ReadByte (http://hackattack:82/JSIL/lib/JSIL.IO.js:1085:28) at Object.ReadHeader (http://hackattack:82/JSIL/lib/XNA/Content.js:686:49) at Object.RawXNBAsset_ReadAsset (http://hackattack:82/JSIL/lib/XNA/XNA4.js:169:19) at Object.ContentManager_Load as Load$b1$30=!!0 at Object.Microsoft_Xna_Framework_Content_ContentManager_Load$b1 (jsil://closure/Microsoft.Xna.Framework.Content.ContentManager.Load`1:7:25) at BoundGenericMethod_Invoke (http://hackattack:82/JSIL/lib/JSIL.Core.js:6130:17 JSIL.Browser.js:199
The external method 'System.Single ReadSingle()' of type 'Microsoft.Xna.Framework.Content.ContentReader' has not been implemented; calling inherited method. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.Read (http://hackattack:82/JSIL/lib/XNA/Content.js:484:27) at readObjectImpl (http://hackattack:82/JSIL/lib/XNA/Content.js:769:23) at Object.ReadObject$b1 as ReadObject$b1$void=!!0 at Object.Microsoft_Xna_Framework_Content_ContentReader_ReadObject$b1 (jsil://closure/Microsoft.Xna.Framework.Content.ContentReader.ReadObject`1:7:25) at BoundGenericMethod_Invoke (http://hackattack:82/JSIL/lib/JSIL.Core.js:6130:17) at Object.RawXNBAsset_ReadAsset (http://hackattack:82/JSIL/lib/XNA/XNA4.js:174:55 JSIL.Browser.js:199
The external method 'HackAttack.Base_Classes.Wave Peek()' of type 'System.Collections.Generic.Queue`1' has not been implemented. at Object.JSIL.Host.warning (http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat (http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub (http://hackattack:82/JSIL/lib/JSIL.Core.js:1306:14) at Object.WaveManager_StartNextWave (http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:1542:30) at Object.WaveManager__ctor (http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:1437:10) at Object.HackAttack_Base_Classes_WaveManager (jsil://closure/HackAttack.Base_Classes.WaveManager:39:21) at Object.Game1_LoadContent (http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:3044:24) at Object.Game_Initialize (http://hackattack:82/JSIL/lib/XNA/XNA4.js:1284:10) at Object.Game1_Initialize (http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:3002:33 HackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1542
Uncaught TypeError: Cannot read property 'Start' of undefined
HackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1542 WaveManager_StartNextWaveHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1437 WaveManager__ctorHackAttack.Base_Classes.WaveManager:39 HackAttack_Base_Classes_WaveManagerHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3044 Game1_LoadContentXNA4.js:1284 Game_InitializeHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3002 Game1_InitializeXNA4.js:1370 Game_Run(index):57 runMainJSIL.Browser.js:1138 browserFinishedLoadingCallback
Queue.Peek looks like the problem here. It's returning undefined instead of a value. ' has not been implemented; calling inherited method.' is often not a problem (but it's worth knowing about if you can't see anything else wrong).
On 29 April 2015 at 13:35, hevans90 notifications@github.com wrote:
So after some troubleshooting I managed to get my XNA content project to compile with JSIL (yay!), and now I notice some errors regarding unimplemented externals, followed by an app crash afterwards, any advice on how to combat this?
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.GameComponentCollection' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.$internalCtor (http://hackattack:82/JSIL/lib/XNA/XNA4.js:1117:10 ) at Object.Microsoft_Xna_Framework_GameComponentCollection_CreateInstanceOfType (jsil://closure/Microsoft.Xna.Framework.GameComponentCollection.CreateInstanceOfType:6:30) at Object.JSIL.CreateInstanceOfType$CacheHit ( http://hackattack:82/JSIL/lib/JSIL.Core.js:8617:14) at Object.JSIL.CreateInstanceOfType$CacheMiss ( http://hackattack:82/JSIL/lib/JSIL.Core.js:8593:15) at Object.JSIL.CreateInstanceOfType ( http://hackattack:82/JSIL/lib/JSIL.Core.js:8643:17) at Object._ctor (http://hackattack:82/JSIL/lib/XNA/XNA4.js:1169:30 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.BlendState' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub as _ctor$void=void http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14 at Object.Microsoft_Xna_Framework_Graphics_BlendState__ctor as _ctor at Object.Microsoft_Xna_Framework_Graphics_BlendState (jsil://closure/Microsoft.Xna.Framework.Graphics.BlendState:15:21) at Function. (http://hackattack:82/JSIL/lib/XNA/Graphics.js:2162:60) at Object.JSIL.$InvokeStaticConstructor ( http://hackattack:82/JSIL/lib/JSIL.Core.js:4465:23) at Object.JSIL.RunStaticConstructors ( http://hackattack:82/JSIL/lib/JSIL.Core.js:4505:12) at MaybeRunStaticConstructors [as initializer] ( http://hackattack:82/JSIL/lib/JSIL.Core.js:6663:12 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'Microsoft.Xna.Framework.Graphics.GraphicsResource' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.ExternalMemberStub as _ctor$void=void http://hackattack:82/JSIL/lib/JSIL.Core.js:1290:39 at Object.Microsoft_Xna_Framework_Graphics_BlendState__ctor as _ctor at Object.Microsoft_Xna_Framework_Graphics_BlendState (jsil://closure/Microsoft.Xna.Framework.Graphics.BlendState:15:21) at Function. (http://hackattack:82/JSIL/lib/XNA/Graphics.js:2162:60) at Object.JSIL.$InvokeStaticConstructor ( http://hackattack:82/JSIL/lib/JSIL.Core.js:4465:23) at Object.JSIL.RunStaticConstructors ( http://hackattack:82/JSIL/lib/JSIL.Core.js:4505:12 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'System.IO.Stream' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at ctorBytesImpl (http://hackattack:82/JSIL/lib/JSIL.IO.js:736:38) at Object._ctor as _ctor$32[622],28=void http://hackattack:82/JSIL/lib/JSIL.IO.js:762:7 at Object.System_IO_MemoryStream__ctor as _ctor at Object.System_IO_MemoryStream (jsil://closure/System.IO.MemoryStream:21:21) at Object.RawXNBAsset_ReadAsset ( http://hackattack:82/JSIL/lib/XNA/XNA4.js:163:24) at Object.ContentManager_Load [as Load$b1$30=!!0] ( http://hackattack:82/JSIL/lib/XNA/Content.js:57:24 JSIL.Browser.js:199
The external method 'void .ctor()' of type 'System.MarshalByRefObject' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1290:39) at ctorBytesImpl (http://hackattack:82/JSIL/lib/JSIL.IO.js:736:38) at Object._ctor as _ctor$32[622],28=void http://hackattack:82/JSIL/lib/JSIL.IO.js:762:7 at Object.System_IO_MemoryStream__ctor as _ctor at Object.System_IO_MemoryStream (jsil://closure/System.IO.MemoryStream:21:21) at Object.RawXNBAsset_ReadAsset ( http://hackattack:82/JSIL/lib/XNA/XNA4.js:163:24 JSIL.Browser.js:199
The external method 'System.Int32 ReadByte()' of type 'System.IO.MemoryStream' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.ReadByte (http://hackattack:82/JSIL/lib/JSIL.IO.js:1085:28) at Object.ReadHeader (http://hackattack:82/JSIL/lib/XNA/Content.js:686:49) at Object.RawXNBAsset_ReadAsset ( http://hackattack:82/JSIL/lib/XNA/XNA4.js:169:19) at Object.ContentManager_Load as Load$b1$30=!!0 http://hackattack:82/JSIL/lib/XNA/Content.js:57:24 at Object.Microsoft_Xna_Framework_Content_ContentManager_Load$b1 (jsil://closure/Microsoft.Xna.Framework.Content.ContentManager.Load`1:7:25) at BoundGenericMethod_Invoke ( http://hackattack:82/JSIL/lib/JSIL.Core.js:6130:17 JSIL.Browser.js:199
The external method 'System.Single ReadSingle()' of type 'Microsoft.Xna.Framework.Content.ContentReader' has not been implemented; calling inherited method. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1283:14) at Object.Read (http://hackattack:82/JSIL/lib/XNA/Content.js:484:27) at readObjectImpl (http://hackattack:82/JSIL/lib/XNA/Content.js:769:23) at Object.ReadObject$b1 as ReadObject$b1$void=!!0 http://hackattack:82/JSIL/lib/XNA/Content.js:775:14 at Object.Microsoft_Xna_Framework_Content_ContentReader_ReadObject$b1 (jsil://closure/Microsoft.Xna.Framework.Content.ContentReader.ReadObject`1:7:25) at BoundGenericMethod_Invoke ( http://hackattack:82/JSIL/lib/JSIL.Core.js:6130:17) at Object.RawXNBAsset_ReadAsset ( http://hackattack:82/JSIL/lib/XNA/XNA4.js:174:55 JSIL.Browser.js:199
The external method 'HackAttack.Base_Classes.Wave Peek()' of type 'System.Collections.Generic.Queue`1' has not been implemented. at Object.JSIL.Host.warning ( http://hackattack:82/JSIL/lib/JSIL.Host.js:152:15) at Object.JSIL.WarningFormat ( http://hackattack:82/JSIL/lib/JSIL.Core.js:10259:13) at Object.ExternalMemberStub ( http://hackattack:82/JSIL/lib/JSIL.Core.js:1306:14) at Object.WaveManager_StartNextWave ( http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:1542:30 ) at Object.WaveManager__ctor ( http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:1437:10 ) at Object.HackAttack_Base_Classes_WaveManager (jsil://closure/HackAttack.Base_Classes.WaveManager:39:21) at Object.Game1_LoadContent ( http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:3044:24 ) at Object.Game_Initialize ( http://hackattack:82/JSIL/lib/XNA/XNA4.js:1284:10) at Object.Game1_Initialize ( http://hackattack:82/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js:3002:33 HackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1542
Uncaught TypeError: Cannot read property 'Start' of undefined
HackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1542 WaveManager_StartNextWaveHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:1437 WaveManager__ctorHackAttack.Base_Classes.WaveManager:39 HackAttack_Base_Classes_WaveManagerHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3044 Game1_LoadContentXNA4.js:1284 Game_InitializeHackAttack, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.js:3002 Game1_InitializeXNA4.js:1370 Game_Run(index):57 runMainJSIL.Browser.js:1138 browserFinishedLoadingCallback
— Reply to this email directly or view it on GitHub https://github.com/sq/JSIL/issues/734#issuecomment-97576694.
Interesting. Am I right in thinking that 'undefined' in JavaScript relates to a variable has been declared but has not yet been assigned a value? Because if so this has me puzzled...
I just checked the C# code of the class that is playing up, and I define a Queue as a field at the top of my class which then gets passed in to the constructor and gets enqueued with objects (Waves in this case) BEFORE any Peeks are invoked. Hence in my C# class the Queue always has values to be Peeked at, so I'm not sure how the JavaScript is managing to find an empty queue :(
Looking at the equivalent JavaScript class the logic seems identical, there is a Queue declared here:
var $T07 = function () { return ($T07 = JSIL.Memoize($asm07.System.Collections.Generic.Queue$b1.Of($asm00.HackAttack.Base_Classes.Wave))) (); };
Below which the class constructor enqueues objects in to the queue:
$T07().prototype.Enqueue.call(this.waves, wave);
And at the very end of the constructor a method is called that Peeks the Queue:
function WaveManager_StartNextWave () { if (((this.waves).get_Count() | 0) > 0) { ($T07().prototype.Peek.call(this.waves)).Start(); this.timeSinceLastWave = 0; this.waveFinished = false; } };
Can you see anything I'm missing?
It doesn't mean the queue is empty, it means the Peek method is unimplemented, so it returns nothing (undefined) and a method call on undefined fails.
'undefined' is a value type in JS, like null or false or true.
On 29 April 2015 at 14:11, hevans90 notifications@github.com wrote:
Interesting. Am I right in thinking that 'undefined' in JavaScript relates to a variable has been declared but has not yet been assigned a value? Because if so this has me puzzled...
I just checked the C# code of the class that is playing up, and I define a Queue as a field at the top of my class which then gets passed in to the constructor and gets enqueued with objects (Waves in this case) BEFORE any Peeks are invoked. Hence in my C# class the Queue always has values to be Peeked at, so I'm not sure how the JavaScript is managing to find an empty queue :(
Looking at the equivalent JavaScript class the logic seems identical, there is a Queue declared here:
_var $T07 = function () { return ($T07 = JSIL.Memoize($asm07.System.Collections.Generic.Queue$b1.Of($asm00.HackAttack.BaseClasses.Wave))) (); };
Below which the class constructor enqueues objects in to the queue:
$T07().prototype.Enqueue.call(this.waves, wave);
And at the very end of the constructor a method is called that Peeks the Queue:
function WaveManager_StartNextWave () { if (((this.waves).getCount() | 0) > 0) { ($T07().prototype.Peek.call(this.waves)).Start();_ this.timeSinceLastWave = 0; this.waveFinished = false; } };
Can you see anything I'm missing?
— Reply to this email directly or view it on GitHub https://github.com/sq/JSIL/issues/734#issuecomment-97586740.
Well I guess that serves me right for trusting the first explanation Google gave me, thank you for explaining what is going on here. I am still confused as to why Peek isn't being implemented though, and am unsure how to go about ensuring it is implemented.
It's probably missing from the bootstrap libraries. I'll do some looking later today.
On 29 April 2015 at 14:36, hevans90 notifications@github.com wrote:
Well I guess that serves me right for trusting the first explanation Google gave me, thank you for explaining what is going on here. I am still confused as to why Peek isn't being implemented though, and am unsure how to go about ensuring it is implemented.
— Reply to this email directly or view it on GitHub https://github.com/sq/JSIL/issues/734#issuecomment-97593328.
Sorry, didn't get to this until now - it appears to be as simple as that Stack.Peek is implemented and Queue.Peek is not. This is pretty trivial to fix and I might be able to check in a fix this week if I find some time. If you'd like to fix it yourself, I'd be happy to guide you through the process and then I can merge your changes in. You'd be essentially adding a method to JSIL.Bootstrap.js's Queue implementation similar to Stack.Peek (above it in the file).
Oh awesome! Sure, I'd love to give it a try. Would it just involve opening the solution in visual studio, editing a .js file and then rebuilding it before running it on my app again? If the Stack.Peek method is already there in the JavaScript somewhere I can probably just copy the syntax for Queue.Peek right?
Apologies for taking so long to get back to you on this, but life as a developer can get stupidly busy sometimes as you probably know...
So I tried to add a new method to the JSIL.bootstrap, mimicking the Stack.Peek() one:
$.Method({ Static: false, Public: true }, "Peek", (new JSIL.MethodSignature(new JSIL.GenericParameter("T", "System.Collections.Generic.Queue`1"), [], [])), function Peek() { if (this._size <= 0) throw new System.InvalidOperationException("Queue is empty"); return this._items[this._size - 1]; } );
I compiled it, re-applied JSIL to my game, and dumped the new output files in to my mockup local website. It worked without any game breaking JS errors this time!
However there is something wrong with the method I added, because the Queues are not acting as they should, and my game sprites simply progress from the first entry in the queue to the last entry, without checking the intermediary ones.
The way I coded it in C# was as such: Sprite has a Queue of integer values representing waypoints on a map. Every game update (some thousands of a second) each sprite checks if it has reached the next value in the queue by Peek()ing the queue, and if it has it will progress on to the next waypoint, repeating such logic until the end of the queue.
I can't see why this would occur, can you?
You mirrored Stack.Peek, what you want is this._items[0].
Excellent, I'll make that change and check it in for you tonight.
I found another issue while we are at it, the C# code I wrote to make the missiles 'homing' is broken when compiled to JScript.
public void SetRotation(float value) // Make the projectiles homing
{
rotation = value;
velocity = Vector2.Transform(new Vector2(0, -speed),
Matrix.CreateRotationZ(rotation));
}
I don't have the JSIL generated JS on me right now at work but it seemed a little strange. There were no 'unimplemented externals' errors though, instead the directional part of the velocity vector is always unchanged, i.e. the bullets shoot straight up and don't chase the targets.
I can obviously manually recode a new method to replace Vector2.Transform, but just thought I should let you know.
JSIL's matrix implementation is a busted hack atm, so that might be why. If you cross-compile monogame or FNA you'll get proper Matrix and Vector implementations.
Hi there, I have only just discovered JSIL and am already a huge fan!
I recently tried to compile my C# XNA 4.0 game using the latest version of JSIL, and it seemed to work fine. I then hosted it locally (using your example web.config and index.html) and the canvas loads fine in Chrome, but when I try to click 'Load Game' inside the canvas the data loads until a certain point in my newly-compiled javascript code and then fails with this error:
Loading data ... failed. Unhandled exception at http://localhost/HackAttack,%20Version=1.0.0.0,%20Culture=neutral,%20PublicKeyToken=null.js line 496: Unable to get property 'MemberwiseClone' of undefined or null reference
So I had a look at the javascript and it stops loading here:
I am no JavaScript developer but from the looks of it, there seems to be an issue with the MemberwiseClone() JavaScript method as noted here: LINK
Just looking at the syntax of the method in the above link suggests that the JavaScript version of MemberwiseClone() needs a colon after it followed by the desired object to clone, and the above auto-generated code doesn't seem to have this colon or object reference.
I'm sure I'm wrong but that's all I could come up with!
Any help would be more than appreciated! Thanks.