6 #include "../../base/errors.h" 61 emp_assert(EM_ASM_INT({
return $0 in js.counts;}, this->
id));
72 EM_ASM_ARGS({js.counts[$0]++;}, this->
id);
78 EM_ASM_ARGS({js.counts[$0]++;}, this->
id);
86 if (js.counts[$0] == 0) {
88 delete js.objects[$0];
101 EM_ASM_ARGS({console.log($0+
":", js.objects[$0]);},
id);
111 js.objects[$0] = d3.tip().attr(
'class',
'd3-tip')
113 .html(
function(d, i) {
return d; });
138 var in_string = Pointer_stringify($1);
139 if (typeof window[
"d3"][in_string] ===
"function"){
140 in_string = window[
"d3"][in_string];
141 }
else if (typeof window[
"emp"][in_string] ===
"function"){
142 in_string = window[
"emp"][in_string];
143 }
else if (typeof window[in_string] ===
"function"){
144 in_string = window[in_string];
147 js.objects[$0] = d3.tip().attr(
'class',
'd3-tip').offset([-10, 0]).html(in_string);
148 }, this->
id, func.c_str());
152 template <
typename T>
156 js.objects[$0] = d3.tip().attr(
'class',
'd3-tip')
158 .html(
emp[$0+
"_html_func"]);
166 var in_string = Pointer_stringify($1);
167 if (typeof window[
"d3"][in_string] ===
"function"){
168 in_string = window[
"d3"][in_string];
169 }
else if (typeof window[
"emp"][in_string] ===
"function"){
170 in_string = window[
"emp"][in_string];
171 }
else if (typeof window[in_string] ===
"function"){
172 in_string = window[in_string];
175 js.objects[$0].html(in_string);
176 }, this->
id, func.c_str());
180 template <
typename T>
184 EM_ASM_ARGS({js.objects[$0].html(
emp[$0+
"_html_func"]);},
id);
195 js.objects[$1] = d3.format(Pointer_stringify($0));
196 }, format.c_str(), this->
id);
199 std::string operator() (
double d){
200 char * buffer = (
char *) EM_ASM_INT({
201 var text = js.objects[$0]($1);
202 var buffer = Module._malloc(text.length+1);
203 Module.writeStringToMemory(text, buffer);
206 std::string result = std::string(buffer);
223 int fail = EM_ASM_INT({
224 var fn = window[
"d3"][Pointer_stringify($2)];
225 if (typeof fn ===
"function") {
229 var fn = window[
"emp"][Pointer_stringify($2)];
230 if (typeof fn ===
"function") {
234 var fn = window[Pointer_stringify($2)];
235 if (typeof fn ===
"function") {
242 }, this->
id, name.c_str());
D3_Base(const D3_Base &other)
Definition: d3_init.h:68
D3_Base & operator=(const D3_Base &other)
Definition: d3_init.h:75
std::string to_string(ALL_TYPES &&...all_values)
Definition: string_utils.h:511
REAL_TYPE sfinae_decoy
Definition: meta.h:93
~D3_Base()
Definition: d3_init.h:82
JSFunction(std::string name)
Definition: d3_init.h:222
JSFunction()
Definition: d3_init.h:221
Catch-all object for storing references to things created in JS.
Definition: d3_init.h:213
int id
Definition: d3_init.h:45
D3_Base()
Default constructor - adds placeholder to js.objects array in Javascript.
Definition: d3_init.h:48
D3_Base(int id)
Definition: d3_init.h:58
Wrapper for creating functions in javascript and calling them there.
Definition: d3_init.h:219
int NextD3ID()
Definition: d3_init.h:31
If we are in emscripten, make sure to include the header.
Definition: array.h:37
void Log() const
Definition: d3_init.h:100
void NotifyWarning(Ts &&...msg)
End user has done something possibly a problem.
Definition: errors.h:141
#define emp_assert(...)
Definition: assert.h:199
JSObject()
Definition: d3_init.h:215
int GetID() const
Definition: d3_init.h:96