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
51
52
53
54
use crate::ArwenApiImpl;
use elrond_wasm::api::EndpointFinishApi;

extern "C" {
	fn finish(dataOffset: *const u8, length: i32);

	// big int API
	fn bigIntFinishUnsigned(bih: i32);
	fn bigIntFinishSigned(bih: i32);

	// small int API
	fn smallIntFinishUnsigned(value: i64);
	fn smallIntFinishSigned(value: i64);

}

/// Interface to only be used by code generated by the macros.
/// The smart contract code doesn't have access to these methods directly.
impl EndpointFinishApi for ArwenApiImpl {
	#[inline]
	fn finish_slice_u8(&self, slice: &[u8]) {
		unsafe {
			finish(slice.as_ptr(), slice.len() as i32);
		}
	}

	#[inline]
	fn finish_big_int_raw(&self, handle: i32) {
		unsafe {
			bigIntFinishSigned(handle);
		}
	}

	#[inline]
	fn finish_big_uint_raw(&self, handle: i32) {
		unsafe {
			bigIntFinishUnsigned(handle);
		}
	}

	#[inline]
	fn finish_u64(&self, value: u64) {
		unsafe {
			smallIntFinishUnsigned(value as i64);
		}
	}

	#[inline]
	fn finish_i64(&self, value: i64) {
		unsafe {
			smallIntFinishSigned(value);
		}
	}
}