leaningtech-dev team mailing list archive
-
leaningtech-dev team
-
Mailing list archive
-
Message #00268
Re: [Question #259087]: Support for associative arrays
Question #259087 on Cheerp changed:
https://answers.launchpad.net/cheerp/+question/259087
Status: Open => Answered
Alessandro Pignotti proposed the following answer:
Ok, now I see, thanks for the information.
We plan to support accessing properties using the [] operator in the
future, but for the moment you need to declare a corresponding C++ type
for the data contained in the JavaScript object. You can do this by
declaring the type in the client namespace (see
https://github.com/leaningtech/cheerp-wiki/wiki/Browser-side-
programming-guide#accessing-the-dom-under-the-hood).
For example:
// Please note that you can add declarations to the client namespace anywhere in your headers or in your cpp files.
// You don't need to modify the system headers provided by cheerp
namespace client
{
struct MyCustomEventData
{
String* get_mystring();
int get_myint();
};
}
void eventHandler(client::CustomEvent* ev)
{
client::MyCustomEventData* data = (client::MyCustomEventData*)ev->get_detail();
client::console.log(data->get_mystring());
}
--
You received this question notification because you are a member of
Leaningtech Team, which is an answer contact for Cheerp.