mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2024-12-03 13:04:58 +00:00
fix build and add license
This commit is contained in:
parent
1e834ca100
commit
3fb874e302
28
LICENSE
Normal file
28
LICENSE
Normal file
@ -0,0 +1,28 @@
|
||||
Copyright (c) 2013, Jyun-Yan You
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the author nor the names of his contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
8
clang.rs
8
clang.rs
@ -1,5 +1,5 @@
|
||||
use std::libc::*;
|
||||
use std::{cast, ptr, str, to_bytes, uint, vec};
|
||||
use std::{cast, ptr, str, to_bytes, vec};
|
||||
|
||||
pub use ll = clangll;
|
||||
use clangll::*;
|
||||
@ -80,7 +80,7 @@ impl Cursor {
|
||||
unsafe {
|
||||
let num = clang_Cursor_getNumArguments(**self) as uint;
|
||||
let mut args = ~[];
|
||||
for uint::range(0, num) |i| {
|
||||
for i in range(0, num) {
|
||||
args.push(Cursor(clang_Cursor_getArgument(**self, i as c_uint)));
|
||||
}
|
||||
return args;
|
||||
@ -184,7 +184,7 @@ impl Type {
|
||||
unsafe {
|
||||
let num = clang_getNumArgTypes(**self) as uint;
|
||||
let mut args = ~[];
|
||||
for uint::range(0, num) |i| {
|
||||
for i in range(0, num) {
|
||||
args.push(Type(clang_getArgType(**self, i as c_uint)));
|
||||
}
|
||||
return args;
|
||||
@ -281,7 +281,7 @@ impl TranslationUnit {
|
||||
unsafe {
|
||||
let num = clang_getNumDiagnostics(**self) as uint;
|
||||
let mut diags = ~[];
|
||||
for uint::range(0, num) |i| {
|
||||
for i in range(0, num) {
|
||||
diags.push(Diagnostic(clang_getDiagnostic(**self, i as c_uint)));
|
||||
}
|
||||
return diags;
|
||||
|
16
gen.rs
16
gen.rs
@ -89,19 +89,20 @@ pub fn gen_rs(out: @io::Writer, abi: ~str, link: &Option<~str>, globs: &[Global]
|
||||
let mut fs = ~[];
|
||||
let mut vs = ~[];
|
||||
let mut gs = ~[];
|
||||
for uniq_globs.iter().advance |g| {
|
||||
uniq_globs.iter().advance(|g| {
|
||||
match *g {
|
||||
GOther => {}
|
||||
GFunc(_) => fs.push(*g),
|
||||
GVar(_) => vs.push(*g),
|
||||
_ => gs.push(*g)
|
||||
}
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
let mut defs = ~[];
|
||||
gs = remove_redundent_decl(gs);
|
||||
|
||||
for gs.iter().advance |g| {
|
||||
gs.iter().advance(|g| {
|
||||
match *g {
|
||||
GType(ti) => defs.push_all(ctypedef_to_rs(&mut ctx, ti.name.clone(), ti.ty)),
|
||||
GCompDecl(ci) => {
|
||||
@ -133,7 +134,8 @@ pub fn gen_rs(out: @io::Writer, abi: ~str, link: &Option<~str>, globs: &[Global]
|
||||
},
|
||||
_ => { }
|
||||
}
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
let vars = do vs.map |v| {
|
||||
match *v {
|
||||
@ -513,7 +515,7 @@ fn cenum_to_rs(ctx: &mut GenCtx, name: ~str, items: ~[@EnumItem], kind: IKind) -
|
||||
let val_ty = cty_to_rs(ctx, ty);
|
||||
let mut def = ty_def;
|
||||
|
||||
for items.iter().advance |it| {
|
||||
items.iter().advance(|it| {
|
||||
let cst = ast::item_static(
|
||||
val_ty.clone(),
|
||||
ast::m_imm,
|
||||
@ -531,7 +533,8 @@ fn cenum_to_rs(ctx: &mut GenCtx, name: ~str, items: ~[@EnumItem], kind: IKind) -
|
||||
};
|
||||
|
||||
def.push(val_def);
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
return def;
|
||||
}
|
||||
@ -618,7 +621,6 @@ fn cfunc_to_rs(ctx: &mut GenCtx, name: ~str, rty: @Type,
|
||||
output: ret,
|
||||
cf: ast::return_val
|
||||
},
|
||||
ast::impure_fn,
|
||||
empty_generics()
|
||||
);
|
||||
|
||||
|
20
main.rs
20
main.rs
@ -106,9 +106,10 @@ fn builtin_names() -> HashSet<~str> {
|
||||
~"__va_list_tag"
|
||||
];
|
||||
|
||||
for keys.consume_iter().advance |s| {
|
||||
keys.consume_iter().advance(|s| {
|
||||
names.insert(s);
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
return names;
|
||||
}
|
||||
@ -145,13 +146,15 @@ fn match_pattern(ctx: @mut BindGenCtx, cursor: &Cursor) -> bool {
|
||||
}
|
||||
|
||||
let name = file.name();
|
||||
for ctx.match_pat.iter().advance |pat| {
|
||||
let mut found = false;
|
||||
ctx.match_pat.iter().advance(|pat| {
|
||||
if name.contains(*pat) {
|
||||
return true;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
return false;
|
||||
return found;
|
||||
}
|
||||
|
||||
fn decl_name(ctx: @mut BindGenCtx, cursor: &Cursor) -> Global {
|
||||
@ -481,12 +484,13 @@ fn main() {
|
||||
|
||||
let mut c_err = false;
|
||||
let diags = unit.diags();
|
||||
for diags.iter().advance |d: &Diagnostic| {
|
||||
diags.iter().advance(|d| {
|
||||
io::stderr().write_line(d.format(Diagnostic::default_opts()));
|
||||
if d.severity() >= CXDiagnostic_Error {
|
||||
c_err = true;
|
||||
}
|
||||
}
|
||||
true
|
||||
});
|
||||
|
||||
if c_err {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user