Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cbindgen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dan Robertson
cbindgen
Commits
95821b3b
Unverified
Commit
95821b3b
authored
Mar 14, 2018
by
Jeremy Soller
Committed by
GitHub
Mar 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from dlrobertson/mod_path_attr
Improve module path parsing
parents
d14295f3
653a328c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
4 deletions
+84
-4
src/bindgen/parser.rs
src/bindgen/parser.rs
+27
-4
tests/expectations/mod_path.c
tests/expectations/mod_path.c
+11
-0
tests/expectations/mod_path.cpp
tests/expectations/mod_path.cpp
+14
-0
tests/rust/mod_path/Cargo.lock
tests/rust/mod_path/Cargo.lock
+4
-0
tests/rust/mod_path/Cargo.toml
tests/rust/mod_path/Cargo.toml
+8
-0
tests/rust/mod_path/cbindgen.toml
tests/rust/mod_path/cbindgen.toml
+2
-0
tests/rust/mod_path/src/lib.rs
tests/rust/mod_path/src/lib.rs
+4
-0
tests/rust/mod_path/src/other.rs
tests/rust/mod_path/src/other.rs
+14
-0
No files found.
src/bindgen/parser.rs
View file @
95821b3b
...
...
@@ -313,12 +313,35 @@ impl Parser {
}
else
if
next_mod_path2
.exists
()
{
self
.parse_mod
(
pkg
,
next_mod_path2
.as_path
())
?
;
}
else
{
// Last chance to find a module path
let
mut
path_attr_found
=
false
;
for
attr
in
&
item
.attrs
{
if
attr
.is_sugared_doc
{
continue
;
}
match
attr
.interpret_meta
()
{
Some
(
syn
::
Meta
::
NameValue
(
syn
::
MetaNameValue
{
ident
,
lit
,
..
}))
=>
{
match
(
ident
.as_ref
(),
lit
)
{
(
"path"
,
syn
::
Lit
::
Str
(
ref
path
))
=>
{
path_attr_found
=
true
;
self
.parse_mod
(
pkg
,
&
mod_dir
.join
(
path
.value
()))
?
;
}
_
=>
(),
}
}
_
=>
(),
}
}
// This should be an error, but it's common enough to
// just elicit a warning
warn!
(
"Parsing crate `{}`: can't find mod {}`."
,
pkg
.name
,
next_mod_name
);
if
!
path_attr_found
{
warn!
(
"Parsing crate `{}`: can't find mod {}`."
,
pkg
.name
,
next_mod_name
);
}
}
}
...
...
tests/expectations/mod_path.c
0 → 100644
View file @
95821b3b
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#define EXPORT_ME_TOO 42
typedef
struct
{
uint64_t
val
;
}
ExportMe
;
void
export_me
(
ExportMe
*
val
);
tests/expectations/mod_path.cpp
0 → 100644
View file @
95821b3b
#include <cstdint>
#include <cstdlib>
static
const
uint8_t
EXPORT_ME_TOO
=
42
;
struct
ExportMe
{
uint64_t
val
;
};
extern
"C"
{
void
export_me
(
ExportMe
*
val
);
}
// extern "C"
tests/rust/mod_path/Cargo.lock
0 → 100644
View file @
95821b3b
[[package]]
name = "mod_path"
version = "0.1.0"
tests/rust/mod_path/Cargo.toml
0 → 100644
View file @
95821b3b
[package]
name
=
"mod_path"
version
=
"0.1.0"
authors
=
["cbindgen"]
[lib]
name
=
"mod_path"
crate-type
=
[
"lib"
,
"dylib"
]
tests/rust/mod_path/cbindgen.toml
0 → 100644
View file @
95821b3b
[parse]
parse_deps
=
false
tests/rust/mod_path/src/lib.rs
0 → 100644
View file @
95821b3b
#[path
=
"other.rs"
]
mod
inner
;
pub
use
inner
::
*
;
tests/rust/mod_path/src/other.rs
0 → 100644
View file @
95821b3b
#[repr(C)]
pub
struct
ExportMe
{
val
:
u64
}
#[repr(C)]
pub
struct
DoNotExportMe
{
val
:
u64
}
pub
const
EXPORT_ME_TOO
:
u8
=
0x2a
;
#[no_mangle]
pub
unsafe
extern
"C"
fn
export_me
(
val
:
*
mut
ExportMe
)
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment