Archived

This forum has been archived. Please start a new discussion on GitHub.

slice2js problem with structs

I'm using Ice 3.6.2 and I have noticed an issue when slice2js produces code for a proxy method which takes a struct as an input parameter. The JS code that is produced is:

"updatePointSource": [, 2, 2, , , , [[7], [DataSetIce.PointSource]], ,
[
DataSetIce.DataSetNotFoundException,
DataSetIce.InvalidDataSetException
], , ]

where DataSetIce.PointSource is an Ice struct. This produces an unknown type error when the JS code is executed.

However, if I put quotes around it like slice2js does for classes then it works so it looks like:

"updatePointSource": [, 2, 2, , , , [[7], ["DataSetIce.PointSource"]], ,
[
DataSetIce.DataSetNotFoundException,
DataSetIce.InvalidDataSetException
], , ]

Looking in the slice2js source code on GitHub, Gen.cpp at line 2063-2067 is where this JS code is generated.

Cheers,

Jason

Tagged:

Comments

  • benoit
    benoit Rennes, France

    Hi,

    Your suggested fix sounds fine but I'd like to make sure I understand why it's required. Could you post a stripped down version of the Slice that exhibits this problem?

    Given that structs can't be forwarded declared (unlike classes), it's not clear to me why the struct type isn't defined when used as an operation parameter.

    Cheers,
    Benoit.

  • Hi Benoit,

    Thanks for getting back to me. Your comment about structs not being forward declared gave me the hint. My Ice javascript files were being included in the wrong order. Having re-ordered them, the problem has been resolved.

    Thanks,

    Jason

  • benoit
    benoit Rennes, France

    Hi,

    Ordering shouldn't be important. In theory, JavaScript generated files generated by slice2js should have require clauses to ensure types included from foreign Slice files are also included in JavaScript before being references. So I'd still be interested in a small test-case that reproduces this issue :smile:. Thanks.

    Cheers,
    Benoit.