-
Notifications
You must be signed in to change notification settings - Fork 0
/
expanded.rs
202 lines (191 loc) · 8.6 KB
/
expanded.rs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#![feature(prelude_import)]
#![no_std]
#![feature(proc_macro)]
#![feature(proc_macro_lib)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
#[macro_use]
extern crate swig_derive;
use swig_derive::{swiggen, swiggen_hack};
#[swig_derive(Default)]
pub struct Test {
pub field: u32,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::default::Default for Test {
#[inline]
fn default() -> Test { Test{field: ::std::default::Default::default(),} }
}
#[doc =
"__SWIG_CODE\n// Wrapper for Rust class Test\nclass Test {\n public:\n ffi::Test *self;\n Test(ffi::Test *ptr) {\n self = ptr;\n };\n ~Test(){\n ffi::__SWIG_INJECT_free_Test(self);\n self = NULL;\n };\n Test() { self = __SWIG_INJECT_default_Test(); };\n};\n__SWIG_END_CODE\n__SWIG_HDR\n// Wrapper for Rust class Test\nclass Test {\n ffi::Test *self;\n public:\n ~Test();\n Test();\n};\n__SWIG_END_HDR\n"]
#[allow(non_camel_case_types)]
struct __SWIG_INJECT_Test;
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_free_Test(arg: *mut Test) {
unsafe {
if !!arg.is_null() {
{
::rt::begin_panic("assertion failed: !arg.is_null()",
&("swig-derive-test/src/lib.rs", 8u32,
19u32))
}
};
&*arg;
}
}
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_default_Test() -> *mut Test {
Box::into_raw(Box::new(Test::default()))
}
#[repr(C)]
pub struct Test2 {
pub field: u32,
}
impl Test {
pub fn new(field: u32) -> Self { Self{field: field,} }
#[allow(non_snake_case)]
#[doc =
"__SWIG_CODE\n__SWIG_END_CODE\n__SWIG_HDR\n\n %extend Test {\n Test(uint32_t field) {\n return new swiggen::Test(ffi::__SWIG_INJECT_ffi_new(field));\n }\n };\n__SWIG_END_HDR\n"]
fn __SWIG_INJECT_hidden_ffi_new() { }
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_ffi_new(field: u32) -> *mut Test {
#[allow(unused_macros)]
macro_rules! ffi_ref(( $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; * $ name }
; ) ; ( @ ref $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; & * $ name
} ; ) ; ( @ prim $ name : ident ) => { } ;);
#[allow(unused_macros)]
macro_rules! box_ptr(( $ x : expr ) => (
Box :: into_raw ( Box :: new ( $ x ) ) ) ; (
@ prim $ x : expr ) => ( $ x ) ;);
let res = Test::new(field);
Box::into_raw(Box::new(res))
}
pub fn get_field(&self) -> u32 { self.field }
#[allow(non_snake_case)]
#[doc =
"__SWIG_CODE\n__SWIG_END_CODE\n__SWIG_HDR\n\n %extend Test {\n uint32_t get_field() {\n return uint32_t(ffi::__SWIG_INJECT_ffi_get_field($self->self));\n }\n };\n__SWIG_END_HDR\n"]
fn __SWIG_INJECT_hidden_ffi_get_field() { }
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_ffi_get_field(wrapped_self: *const Test)
-> u32 {
#[allow(unused_macros)]
macro_rules! ffi_ref(( $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; * $ name }
; ) ; ( @ ref $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; & * $ name
} ; ) ; ( @ prim $ name : ident ) => { } ;);
#[allow(unused_macros)]
macro_rules! box_ptr(( $ x : expr ) => (
Box :: into_raw ( Box :: new ( $ x ) ) ) ; (
@ prim $ x : expr ) => ( $ x ) ;);
let wrapped_self =
unsafe {
if !!wrapped_self.is_null() {
{
::rt::begin_panic("assertion failed: !wrapped_self.is_null()",
&("swig-derive-test/src/lib.rs",
20u32, 1u32))
}
};
&*wrapped_self
};
let res = Test::get_field(wrapped_self);
res
}
}
#[allow(non_snake_case)]
#[doc =
"__SWIG_CODE\n__SWIG_END_CODE\n__SWIG_HDR\n\n %extend Test {\n Test(uint32_t field) {\n return new swiggen::Test(ffi::__SWIG_INJECT_ffi_new(field));\n }\n };\n__SWIG_END_HDR\n"]
fn __SWIG_INJECT_hidden_ffi_new() { }
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_ffi_new(field: u32) -> *mut Test {
#[allow(unused_macros)]
macro_rules! ffi_ref(( $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; * $ name } ; )
; ( @ ref $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; & * $ name } ;
) ; ( @ prim $ name : ident ) => { } ;);
#[allow(unused_macros)]
macro_rules! box_ptr(( $ x : expr ) => (
Box :: into_raw ( Box :: new ( $ x ) ) ) ; (
@ prim $ x : expr ) => ( $ x ) ;);
let res = Test::new(field);
Box::into_raw(Box::new(res))
}
#[allow(non_snake_case)]
#[doc =
"__SWIG_CODE\n__SWIG_END_CODE\n__SWIG_HDR\n\n %extend Test {\n uint32_t get_field() {\n return uint32_t(ffi::__SWIG_INJECT_ffi_get_field($self->self));\n }\n };\n__SWIG_END_HDR\n"]
fn __SWIG_INJECT_hidden_ffi_get_field() { }
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_ffi_get_field(wrapped_self: *const Test)
-> u32 {
#[allow(unused_macros)]
macro_rules! ffi_ref(( $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; * $ name } ; )
; ( @ ref $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; & * $ name } ;
) ; ( @ prim $ name : ident ) => { } ;);
#[allow(unused_macros)]
macro_rules! box_ptr(( $ x : expr ) => (
Box :: into_raw ( Box :: new ( $ x ) ) ) ; (
@ prim $ x : expr ) => ( $ x ) ;);
let wrapped_self =
unsafe {
if !!wrapped_self.is_null() {
{
::rt::begin_panic("assertion failed: !wrapped_self.is_null()",
&("swig-derive-test/src/lib.rs", 20u32,
1u32))
}
};
&*wrapped_self
};
let res = Test::get_field(wrapped_self);
res
}
pub fn test_function() -> Test { Test::new(5) }
#[allow(non_snake_case)]
#[doc =
"__SWIG_CODE\nTest test_function() {\n return Test(ffi::__SWIG_INJECT_ffi_test_function());\n }__SWIG_END_CODE\n__SWIG_HDR\nTest test_function();__SWIG_END_HDR\n"]
fn __SWIG_INJECT_hidden_ffi_test_function() { }
#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn __SWIG_INJECT_ffi_test_function() -> *mut Test {
#[allow(unused_macros)]
macro_rules! ffi_ref(( $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; * $ name } ; )
; ( @ ref $ name : ident ) => (
let $ name = unsafe {
assert ! ( ! $ name . is_null ( ) ) ; & * $ name } ;
) ; ( @ prim $ name : ident ) => { } ;);
#[allow(unused_macros)]
macro_rules! box_ptr(( $ x : expr ) => (
Box :: into_raw ( Box :: new ( $ x ) ) ) ; (
@ prim $ x : expr ) => ( $ x ) ;);
let res = ::test_function();
Box::into_raw(Box::new(res))
}
#[no_mangle]
pub extern "C" fn test_value() -> u32 { Test::new(13).field }
#[no_mangle]
pub extern "C" fn test2_func() -> Test2 { Test2{field: 12,} }