Skip to content

Instantly share code, notes, and snippets.

function ___wrapper___ZN6client8documentE(){
return document;
}
(module
(type (;0;) (func (param i32) (result anyref)))
(type (;1;) (func (param anyref anyref) (result anyref)))
(type (;2;) (func (param anyref anyref)))
(type (;3;) (func (result anyref)))
(type (;4;) (func))
(import "i" "___wrapper__cheerpCreate_ZN6client6StringC2EPKc" (func (;0;) (type 0)))
(import "i" "___wrapper___ZN6client8Document13createElementERKNS_6StringE" (func (;1;) (type 1)))
(import "i" "___wrapper___ZN6client7Element13set_classNameERKNS_6StringE" (func (;2;) (type 2)))
(import "i" "___wrapper___ZN6client8documentE" (func (;3;) (type 3)))
@yuri91
yuri91 / anyref4.cpp
Last active May 15, 2020 09:43
Access client globals
#include <cheerp/client.h>
[[cheerp::wasm]]
[[cheerp::jsexport]]
client::Element* global(const char* cl)
{
client::String* clJS = new client::String(cl);
client::Element* elem = client::document.createElement("div");
elem->set_className(*clJS);
return elem;
function ___wrapper__cheerpCreate_ZN6client4DateC1Eddd(Larg0,Larg1,Larg2){
Larg0=+Larg0;
Larg1=+Larg1;
Larg2=+Larg2;
return new Date(Larg0,Larg1,Larg2);
}
(module
(type (;0;) (func (param f64 f64 f64) (result anyref)))
(type (;1;) (func))
(type (;2;) (func (result anyref)))
(import "i" "___wrapper__cheerpCreate_ZN6client4DateC1Eddd" (func (;0;) (type 0)))
(func $__wasm_nullptr (type 1)
unreachable)
(func $_Z18constructAndReturnv (type 2) (result anyref)
f64.const 0x1.f9p+10 (;=2020;)
f64.const 0x1.4p+2 (;=5;)
@yuri91
yuri91 / anyref3.cpp
Last active May 15, 2020 09:43
Create new client objects
#include <cheerp/client.h>
[[cheerp::wasm]]
[[cheerp::jsexport]]
client::Date* constructAndReturn()
{
client::Date* d = new client::Date(2020, 5, 15);
return d;
}
function ___wrapper___ZN6client7Element6scrollEdd(Larg0,Larg1,Larg2){
Larg0=Larg0;
Larg1=+Larg1;
Larg2=+Larg2;
Larg0.scroll(Larg1,Larg2);
}
(module
(type (;0;) (func (param anyref f64 f64)))
(type (;1;) (func))
(type (;2;) (func (param anyref)))
(import "i" "___wrapper___ZN6client7Element6scrollEdd" (func (;0;) (type 0)))
(func $__wasm_nullptr (type 1)
unreachable)
(func $_Z11callMethodsPN6client7ElementE (type 2) (param anyref)
local.get 0
f64.const 0x0p+0 (;=0;)
@yuri91
yuri91 / anyref2.cpp
Last active May 15, 2020 09:40
Call methods on anyref values
#include <cheerp/client.h>
namespace [[cheerp::genericjs]] client {
void jsFunc(client::Element* elem);
}
[[cheerp::wasm]]
[[cheerp::jsexport]]
void callMethods(client::Element* elem)
{
(module
(type (;0;) (func (param anyref)))
(type (;1;) (func))
(type (;2;) (func (param anyref) (result anyref)))
(import "i" "__ZN6client6jsFuncEPNS_7ElementE" (func (;0;) (type 0)))
(func $__wasm_nullptr (type 1)
unreachable)
(func $_Z13passAndReturnPN6client7ElementE (type 2) (param anyref) (result anyref)
local.get 0
call 0