Add support for adding "using namespace" statements
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
8e4db4c17f
commit
4bd7b07d2f
@@ -217,6 +217,14 @@ impl Bindings {
|
||||
}
|
||||
|
||||
if self.config.language == Language::Cxx || self.config.cpp_compat {
|
||||
if let Some(ref using) = self.config.using {
|
||||
for namespace in using {
|
||||
out.new_line();
|
||||
write!(out, "using namespace {};", namespace);
|
||||
}
|
||||
out.new_line();
|
||||
}
|
||||
|
||||
out.new_line();
|
||||
out.write("extern \"C\" {");
|
||||
out.new_line();
|
||||
|
||||
@@ -621,6 +621,8 @@ pub struct Config {
|
||||
pub namespace: Option<String>,
|
||||
/// An optional list of namespaces. Only applicable when language="C++"
|
||||
pub namespaces: Option<Vec<String>>,
|
||||
/// An optional list of namespaces to ddeclare as using. Only applicable when language="C++"
|
||||
pub using: Option<Vec<String>>,
|
||||
/// The style to use for braces
|
||||
pub braces: Braces,
|
||||
/// The preferred length of a line, used for auto breaking function arguments
|
||||
@@ -672,6 +674,7 @@ impl Default for Config {
|
||||
no_includes: false,
|
||||
namespace: None,
|
||||
namespaces: None,
|
||||
using: None,
|
||||
braces: Braces::SameLine,
|
||||
line_length: 100,
|
||||
tab_width: 2,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void root(void);
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void root(void);
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void root(void);
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
void root(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
|
||||
void root();
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,3 @@
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root() {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
using = ["std"]
|
||||
Reference in New Issue
Block a user