Skip to content

Commit

Permalink
feat: Support query is_pure_virtual option
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Apr 13, 2024
1 parent 0258897 commit 45fa9a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ SELECT DISTINCT name AS function_name FROM functions

### Functions table structure

| Name | Type | Description |
| ------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | Text | Function or Method name |
| signature | Text | Parameters and return type literal |
| args_count | Integer | Number of arguments |
| class_name | Text | Return class name for method |
| return_type | Text | Return type literal |
| is_method | Boolean | True if it's a method |
| is_virtual | Boolean | Return true if a C++ member function or member function template is explicitly declared 'virtual' or if it overrides a virtual method from one of the base classes |
| has_template | Boolean | True if it's has template |
| Name | Type | Description |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name | Text | Function or Method name |
| signature | Text | Parameters and return type literal |
| args_count | Integer | Number of arguments |
| class_name | Text | Return class name for method |
| return_type | Text | Return type literal |
| is_method | Boolean | True if it's a method |
| is_virtual | Boolean | Return true if a C++ member function or member function template is explicitly declared 'virtual' or if it overrides a virtual method from one of the base classes |
| is_pure_virtual | Boolean | Return ture if a C++ member function or member function template is pure virtual. |
| has_template | Boolean | True if it's has template |

---

Expand Down
8 changes: 8 additions & 0 deletions src/clang_function_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct FunctionNode {
pub class_name: String,
pub is_method: bool,
pub is_virtual: bool,
pub is_pure_virtual: bool,
pub has_template: bool,
}

Expand Down Expand Up @@ -96,6 +97,12 @@ extern "C" fn visit_children(
false
};

let is_pure_virtual = if is_method {
clang_CXXMethod_isPureVirtual(cursor) != 0
} else {
false
};

functions.push(FunctionNode {
name: name.to_string(),
signature: signature.to_string(),
Expand All @@ -104,6 +111,7 @@ extern "C" fn visit_children(
class_name,
is_method,
is_virtual,
is_pure_virtual,
has_template,
});

Expand Down
5 changes: 5 additions & 0 deletions src/data_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ fn select_functions(
continue;
}

if field_name == "is_pure_virtual" {
values.push(Value::Boolean(function.is_pure_virtual));
continue;
}

if field_name == "has_template" {
values.push(Value::Boolean(function.has_template));
continue;
Expand Down
2 changes: 2 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ lazy_static! {
map.insert("class_name", DataType::Text);
map.insert("is_method", DataType::Boolean);
map.insert("is_virtual", DataType::Boolean);
map.insert("is_pure_virtual", DataType::Boolean);
map.insert("has_template", DataType::Boolean);
map
};
Expand All @@ -30,6 +31,7 @@ lazy_static! {
"class_name",
"is_method",
"is_virtual",
"is_pure_virtual",
"has_template",
],
);
Expand Down

0 comments on commit 45fa9a9

Please sign in to comment.