leaningtech / cheerp-meta

Cheerp - a C/C++ compiler for Web applications - compiles to WebAssembly and JavaScript
https://labs.leaningtech.com/cheerp
Other
1.03k stars 51 forks source link

Passing C++ pointer to callback doesn't compile, such as "this". #80

Closed vdcoder closed 6 years ago

vdcoder commented 6 years ago

Built with:

c:\cheerp\bin\clang++ -target cheerp -cheerp-mode=wasm -cheerp-linear-heap-size=128 -cheerp-wasm-loader=loader.js -o output.wasm main.cpp -g -cheerp-sourcemap=output.js.map

Bare example:

include <cheerp/client.h>

include <cheerp/clientlib.h>

class [[cheerp::genericjs]] foo { public: void StartTimer(); private: void MyMemberFunction(); };

void foo::StartTimer() { client::setInterval(cheerp::Callback([this](client::Event* e){this->MyMemberFunction();}), 1000); }

void foo::MyMemberFunction() { client::alert(L"Hello"); }

foo * pFoo;

[[cheerp::genericjs]] void webMain() { pFoo = new foo(); pFoo->StartTimer(); }

Error:

c:\cheerp\bin/../include/c++/v1\functional:1570:9: error: Cheerp: Wasm function 'operator()' cannot take parameter '' of non-wasm type 'client::Event ' _Rp operator()(_ArgTypes...) const; ^ c:\cheerp\bin/../include/client\cheerp/client.h:73:11: note: in instantiation of template class 'std::function<void (client::Event )>' requested here new std::function(func));

alexp-sssup commented 6 years ago

This bug was present in RC2, but it is already fixed in current master. We provide daily builds on for Linux at this time, do you have any change to test using a daily Linux build from here? https://launchpad.net/~leaningtech-dev/+archive/ubuntu/cheerp-nightly-ppa

vdcoder commented 6 years ago

sudo add-apt-repository ppa:leaningtech-dev/cheerp-ppa

[sudo] password for victor: Installation instructions on the wiki: https://github.com/leaningtech/cheerp-wiki/wiki/Ubuntu-Debian-installation-using-PPA More info: https://launchpad.net/~leaningtech-dev/+archive/ubuntu/cheerp-ppa Press [ENTER] to continue or Ctrl-c to cancel adding it.

Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease

Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease

Hit:4 http://dl.google.com/linux/chrome/deb stable Release

Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease

Ign:6 http://ppa.launchpad.net/leaningtech-dev/cheerp-ppa/ubuntu bionic InRelease Hit:7 http://security.ubuntu.com/ubuntu bionic-security InRelease Err:9 http://ppa.launchpad.net/leaningtech-dev/cheerp-ppa/ubuntu bionic Release 404 Not Found [IP: 91.189.95.83 80] Reading package lists... Done FATAL -> Failed to fork.

Do you know why I cannot do add-apt-repository, I have latest Kubunto, from today.

Thanks,

Victor Diaz

On Fri, Jul 13, 2018 at 2:04 AM, Alessandro Pignotti < notifications@github.com> wrote:

This bug was present in RC2, but it is already fixed in current master. We provide daily builds on for Linux at this time, do you have any change to test using a daily Linux build from here? https://launchpad.net/~ leaningtech-dev/+archive/ubuntu/cheerp-nightly-ppa https://launchpad.net/%7Eleaningtech-dev/+archive/ubuntu/cheerp-nightly-ppa

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/leaningtech/cheerp-meta/issues/80#issuecomment-404735206, or mute the thread https://github.com/notifications/unsubscribe-auth/ABeFsSqttTCOb-JslFNLpEVP8lhEM1l1ks5uGDh-gaJpZM4VNxmN .

-- Victor Diaz Senior Software Engineer (305)-322-0486

alexp-sssup commented 6 years ago

You need to use the Nightly build PPA, the release PPA does not support bionic for now.

https://launchpad.net/~leaningtech-dev/+archive/ubuntu/cheerp-nightly-ppa