1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use elrond_wasm::api::Handle;
#[allow(dead_code)]
extern "C" {
fn mBufferNew() -> i32;
fn bigIntNew(value: i64) -> i32;
fn mBufferToBigIntUnsigned(mBufferHandle: i32, bigIntHandle: i32) -> i32;
fn mBufferToBigIntSigned(mBufferHandle: i32, bigIntHandle: i32) -> i32;
fn mBufferFromBigIntUnsigned(mBufferHandle: i32, bigIntHandle: i32) -> i32;
fn mBufferFromBigIntSigned(mBufferHandle: i32, bigIntHandle: i32) -> i32;
}
impl elrond_wasm::api::ManagedTypeApi for crate::VmApiImpl {
#[inline]
fn mb_to_big_int_unsigned(&self, buffer_handle: Handle) -> Handle {
unsafe {
let big_int_handle = bigIntNew(0);
mBufferToBigIntUnsigned(buffer_handle, big_int_handle);
big_int_handle
}
}
#[inline]
fn mb_to_big_int_signed(&self, buffer_handle: Handle) -> Handle {
unsafe {
let big_int_handle = bigIntNew(0);
mBufferToBigIntSigned(buffer_handle, big_int_handle);
big_int_handle
}
}
#[inline]
fn mb_from_big_int_unsigned(&self, big_int_handle: Handle) -> Handle {
unsafe {
let buffer_handle = mBufferNew();
mBufferFromBigIntUnsigned(buffer_handle, big_int_handle);
buffer_handle
}
}
#[inline]
fn mb_from_big_int_signed(&self, big_int_handle: Handle) -> Handle {
unsafe {
let buffer_handle = mBufferNew();
mBufferFromBigIntSigned(buffer_handle, big_int_handle);
buffer_handle
}
}
}