Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
26bb0f15
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
26bb0f15
编写于
1月 10, 2020
作者:
J
John VanEnk
提交者:
Eduard-Mihai Burtescu
2月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add similar examples that work to each test.
上级
f1b52b34
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
6 deletion
+87
-6
src/test/run-make-fulldeps/arguments-non-c-like-enum/nonclike.rs
...t/run-make-fulldeps/arguments-non-c-like-enum/nonclike.rs
+18
-2
src/test/run-make-fulldeps/arguments-non-c-like-enum/test.c
src/test/run-make-fulldeps/arguments-non-c-like-enum/test.c
+29
-3
src/test/run-make-fulldeps/return-non-c-like-enum/nonclike.rs
...test/run-make-fulldeps/return-non-c-like-enum/nonclike.rs
+11
-0
src/test/run-make-fulldeps/return-non-c-like-enum/test.c
src/test/run-make-fulldeps/return-non-c-like-enum/test.c
+29
-1
未找到文件。
src/test/run-make-fulldeps/arguments-non-c-like-enum/nonclike.rs
浏览文件 @
26bb0f15
#![crate_type
=
"lib"
]
#![crate_name
=
"nonclike"
]
#[repr(C,u8)]
#[repr(C,
u8)]
pub
enum
TT
{
AA
(
u64
,
u64
),
BB
,
}
#[no_mangle]
pub
extern
"C"
fn
tt_add
(
a
:
TT
,
b
:
TT
)
->
u64
{
match
(
a
,
b
)
{
(
TT
::
AA
(
a1
,
b1
),
TT
::
AA
(
a2
,
b2
))
=>
a1
+
a2
+
b1
+
b2
,
(
TT
::
AA
(
a1
,
b1
),
TT
::
BB
)
=>
a1
+
b1
,
(
TT
::
BB
,
TT
::
AA
(
a1
,
b1
))
=>
a1
+
b1
,
_
=>
0
,
}
}
#[repr(C,
u8)]
pub
enum
T
{
A
(
u64
),
B
,
...
...
@@ -9,7 +25,7 @@ pub enum T {
#[no_mangle]
pub
extern
"C"
fn
t_add
(
a
:
T
,
b
:
T
)
->
u64
{
match
(
a
,
b
)
{
match
(
a
,
b
)
{
(
T
::
A
(
a
),
T
::
A
(
b
))
=>
a
+
b
,
(
T
::
A
(
a
),
T
::
B
)
=>
a
,
(
T
::
B
,
T
::
A
(
b
))
=>
b
,
...
...
src/test/run-make-fulldeps/arguments-non-c-like-enum/test.c
浏览文件 @
26bb0f15
...
...
@@ -3,6 +3,26 @@
#include <stdio.h>
/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
* type in nonclike.rs . */
enum
TT_Tag
{
AA
,
BB
,
};
typedef
uint8_t
TT_Tag
;
typedef
struct
{
uint64_t
_0
;
uint64_t
_1
;
}
AA_Body
;
typedef
struct
{
TT_Tag
tag
;
union
{
AA_Body
aa
;
};
}
TT
;
/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
* in nonclike.rs . */
enum
T_Tag
{
...
...
@@ -22,18 +42,24 @@ typedef struct {
};
}
T
;
/* Th
is symbol is
defined by the Rust staticlib built from
/* Th
ese symbols are
defined by the Rust staticlib built from
* nonclike.rs. */
extern
uint64_t
t_add
(
T
a
,
T
b
);
extern
uint64_t
tt_add
(
TT
a
,
TT
b
);
int
main
(
int
argc
,
char
*
argv
[])
{
(
void
)
argc
;
(
void
)
argv
;
/* This example works. */
TT
xx
=
{
.
tag
=
AA
,
.
aa
=
{
.
_0
=
1
,
.
_1
=
2
}
};
TT
yy
=
{
.
tag
=
AA
,
.
aa
=
{
.
_0
=
10
,
.
_1
=
20
}
};
uint64_t
rr
=
tt_add
(
xx
,
yy
);
assert
(
33
==
rr
);
/* This one returns an incorrect result. */
T
x
=
{
.
tag
=
A
,
.
a
=
{
.
_0
=
1
}
};
T
y
=
{
.
tag
=
A
,
.
a
=
{
.
_0
=
10
}
};
uint64_t
r
=
t_add
(
x
,
y
);
assert
(
11
==
r
);
return
0
;
...
...
src/test/run-make-fulldeps/return-non-c-like-enum/nonclike.rs
浏览文件 @
26bb0f15
#![crate_type
=
"lib"
]
#![crate_name
=
"nonclike"
]
#[repr(C,
u8)]
pub
enum
TT
{
AA
(
u64
,
u64
),
BB
,
}
#[no_mangle]
pub
extern
"C"
fn
tt_new
(
a
:
u64
,
b
:
u64
)
->
TT
{
TT
::
AA
(
a
,
b
)
}
#[repr(C,u8)]
pub
enum
T
{
A
(
u64
),
...
...
src/test/run-make-fulldeps/return-non-c-like-enum/test.c
浏览文件 @
26bb0f15
#include <stdint.h>
#include <assert.h>
/* This is the code generated by cbindgen 0.12.1 for the `enum TT`
* type in nonclike.rs . */
enum
TT_Tag
{
AA
,
BB
,
};
typedef
uint8_t
TT_Tag
;
typedef
struct
{
uint64_t
_0
;
uint64_t
_1
;
}
AA_Body
;
typedef
struct
{
TT_Tag
tag
;
union
{
AA_Body
aa
;
};
}
TT
;
/* This is the code generated by cbindgen 0.12.1 for the `enum T` type
* in nonclike.rs . */
enum
T_Tag
{
...
...
@@ -20,13 +40,21 @@ typedef struct {
};
}
T
;
/* Th
is symbol is
defined by the Rust staticlib built from
/* Th
ese symbols are
defined by the Rust staticlib built from
* nonclike.rs. */
extern
TT
tt_new
(
uint64_t
a
,
uint64_t
b
);
extern
T
t_new
(
uint64_t
v
);
int
main
(
int
argc
,
char
*
argv
[])
{
(
void
)
argc
;
(
void
)
argv
;
/* This example works. */
TT
tt
=
tt_new
(
10
,
20
);
assert
(
AA
==
tt
.
tag
);
assert
(
10
==
tt
.
aa
.
_0
);
assert
(
20
==
tt
.
aa
.
_1
);
/* This one segfaults. */
T
t
=
t_new
(
10
);
assert
(
A
==
t
.
tag
);
assert
(
10
==
t
.
a
.
_0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录