Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/embind/test_unsigned.cpp
4150 views
1
// Copyright 2017 The Emscripten Authors. All rights reserved.
2
// Emscripten is available under two separate licenses, the MIT license and the
3
// University of Illinois/NCSA Open Source License. Both these licenses can be
4
// found in the LICENSE file.
5
6
#include <emscripten/bind.h>
7
#include <emscripten/emscripten.h>
8
#include <cstdio>
9
static void set_bind_f64(emscripten::val val) {
10
printf("set_bind_f64: %x\n", (uint32_t)val.as<double>());
11
}
12
static void set_bind_u64(emscripten::val val) {
13
printf("set_bind_u64: %x\n", (uint32_t)val.as<uint64_t>());
14
}
15
static void set_bind_u32(emscripten::val val) {
16
printf("set_bind_u32: %x\n", val.as<uint32_t>());
17
}
18
extern "C" {
19
EMSCRIPTEN_KEEPALIVE void set_c_u64(uint64_t v) {
20
printf("set_c_u64: %x\n", (uint32_t)v);
21
}
22
EMSCRIPTEN_KEEPALIVE void set_c_u32(uint32_t v) {
23
printf("set_c_u32: %x\n", v);
24
}
25
}
26
EMSCRIPTEN_BINDINGS(TEST) {
27
emscripten::function("set_bind_f64", &set_bind_f64);
28
emscripten::function("set_bind_u64", &set_bind_u64);
29
emscripten::function("set_bind_u32", &set_bind_u32);
30
}
31
32
int main()
33
{
34
EM_ASM(
35
Module['set_bind_f64'](2147483648);
36
// Module['set_bind_u64'](2147483648); // todo: embind does not currently support 64-bit integers.
37
Module['set_bind_u32'](2147483648);
38
// Module['_set_c_u64'](2147483648); // todo: embind does not currently support 64-bit integers.
39
_set_c_u32(2147483648);
40
);
41
}
42
43