It seems like it is possible to get the code of a function in JavaScript, and that it is as simple as:
function foo() {...}
foo.toString()
However, doing that in QML gives me a rather uninspiring function () { [code] }
So is there a way to get the [code]
part as well? I also tried JSON.stringify()
but it didn't do any good.
I'd like to sum up the discussion that took place in the comments, for this can be a good response for future searches.
As already stated in the comments, it looks to be a noticeable bug of QML. Here they claim that:
the QML runtime implements the ECMAScript Language Specification standard
Anyway, it actually doesn't.
Thanks to Meetfe, here is the link to the open bug regarding the issue.
The same error seems to be here, where they suggest to look at the reference for further details:
For a detailed description, see the ECMA-262 specification.
It is (at least, it looks to me) a claim of full compatibility and once more it makes me think to a bug, rather than a partial implementation of the specification.
So, unfortunately that is the intended way to stringify a function (it makes sense indeed, for it is an Ecmascript compliant environment), but it doesn't work correctly in QML, even though it should as stated in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With