Skip to content

Commit 46f4c9e

Browse files
committed
Rename cfg to target_os
1 parent 1b82f10 commit 46f4c9e

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

cpp2rust/converter/translation_rule.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ TypeRule ParseTypeRuleJSON(const llvm::json::Object &obj) {
130130
return rule;
131131
}
132132

133-
bool CfgMatchesHost(llvm::StringRef cfg) {
133+
bool TargetOSMatchesHost(llvm::StringRef target_os) {
134134
#if defined(__linux__)
135-
return cfg == "linux";
135+
return target_os == "linux";
136136
#elif defined(__APPLE__)
137-
return cfg == "macos";
137+
return target_os == "macos";
138138
#else
139139
return false;
140140
#endif
@@ -163,7 +163,8 @@ void LoadTgtFromIR(ExprRules &exprs, TypeRules &types,
163163
if (!obj)
164164
continue;
165165

166-
if (auto cfg = obj->getString("cfg"); cfg && !CfgMatchesHost(*cfg)) {
166+
if (auto target_os = obj->getString("target_os");
167+
target_os && !TargetOSMatchesHost(*target_os)) {
167168
continue;
168169
}
169170

rule-preprocessor/src/ir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct TypeInfo {
5050
pub struct FnIr {
5151
pub body: Vec<BodyFragment>,
5252
#[serde(skip_serializing_if = "Option::is_none")]
53-
pub cfg: Option<String>,
53+
pub target_os: Option<String>,
5454
#[serde(skip_serializing_if = "Option::is_none")]
5555
pub generics: Option<BTreeMap<String, Vec<String>>>,
5656
#[serde(skip_serializing_if = "Option::is_none")]

rule-preprocessor/src/syntactic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'a> FnIrBuilder<'a> {
258258
Self { fn_item }
259259
}
260260

261-
fn cfg_target_os(&self) -> Option<String> {
261+
fn get_target_os(&self) -> Option<String> {
262262
use ast::HasAttrs;
263263
for attr in self.fn_item.attrs() {
264264
let meta_text = attr.meta()?.syntax().text().to_string();
@@ -524,7 +524,7 @@ impl<'a> FnIrBuilder<'a> {
524524
},
525525
multi_statement,
526526
body,
527-
cfg: self.cfg_target_os(),
527+
target_os: self.get_target_os(),
528528
};
529529
ir.validate(&format!("{}:{}", path.display(), fn_name));
530530
ir

rules/socket/ir_unsafe.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"text": "libc::SOCK_CLOEXEC"
3636
}
3737
],
38-
"cfg": "linux",
38+
"target_os": "linux",
3939
"return_type": {
4040
"type": "i32"
4141
}
@@ -46,7 +46,7 @@
4646
"text": "libc::SOCK_NONBLOCK"
4747
}
4848
],
49-
"cfg": "linux",
49+
"target_os": "linux",
5050
"return_type": {
5151
"type": "i32"
5252
}

0 commit comments

Comments
 (0)