diff --git a/README.md b/README.md index 6bd50e1..7c1580b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ SELECT DISTINCT name AS function_name FROM functions SELECT * FROM globals SELECT COUNT(name) from globals WHERE type = "int" +SELECT * FROM globals WHERE is_volatile ``` --- @@ -64,10 +65,11 @@ SELECT COUNT(name) from globals WHERE type = "int" ### Gloal variables table structure -| Name | Type | Description | -| ---- | ---- | ---------------------------- | -| name | Text | Global variable name | -| type | Text | Global variable type literal | +| Name | Type | Description | +| ----------- | ------- | --------------------------------- | +| name | Text | Global variable name | +| type | Text | Global variable type literal | +| is_volatile | Boolean | True if variable type is volatile | --- diff --git a/src/data_provider.rs b/src/data_provider.rs index 736a441..f5bf4f5 100644 --- a/src/data_provider.rs +++ b/src/data_provider.rs @@ -217,6 +217,11 @@ fn select_variables( continue; } + if field_name == "is_volatile" { + values.push(Value::Boolean(variable.is_volatile)); + continue; + } + values.push(Value::Null); } diff --git a/src/schema.rs b/src/schema.rs index 4892152..2e6826d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -19,6 +19,7 @@ lazy_static! { map.insert("has_template", DataType::Boolean); map.insert("access_modifier", DataType::Integer); map.insert("is_variadic", DataType::Boolean); + map.insert("is_volatile", DataType::Boolean); map }; } @@ -44,7 +45,7 @@ lazy_static! { "is_variadic", ], ); - map.insert("globals", vec!["name", "type"]); + map.insert("globals", vec!["name", "type", "is_volatile"]); map }; } diff --git a/src/visitor/globals.rs b/src/visitor/globals.rs index 6adaa58..a0b38bb 100644 --- a/src/visitor/globals.rs +++ b/src/visitor/globals.rs @@ -9,6 +9,7 @@ use std::ptr; pub struct GlobalVariableNode { pub name: String, pub type_literal: String, + pub is_volatile: bool, } pub fn select_clang_variables(path: &str) -> Vec { @@ -62,9 +63,12 @@ extern "C" fn visit_children( CStr::from_ptr(clang_getCString(clang_getTypeSpelling(field_type))) .to_string_lossy(); + let is_volatile = clang_isVolatileQualifiedType(field_type) != 0; + variables.push(GlobalVariableNode { name: field_name_str.to_string(), type_literal: field_type_str.to_string(), + is_volatile, }); clang_disposeString(field_name);